#include <iostream.h> main() { int number, right_digit; cout << "Enter your number\n"; cin >> number; while (number !=0) { right_digit = number % 10; cout >> right_digit; number /= 10; } cout << "\n"; }
#include <iostream.h> main() { int number; const int min = 1; const int max = 100; number = 0; while ( number < min || number > max) { cout << "Enter a number in the range 1 to 100\n"; cin >> number; } cout << "the number is in range\n"; }
#include <iostream.h> main() { char letter; cout << "Press Y to continue\n"; do { letter = getchar(); } while (letter != 'y' && letter != 'Y'); cout << "program execution will continue\n"; }
#include <iostream.h> main() { float inches,centimetres; // print table header cout << "inches\t centimetres\n"; //calculate and print table entries for (inches = 1; inches <=10 ; inches += 0.5) { centimetres = 2.54 * inches; cout << inches << centimetres << "\n"; } }
Back to Main Page for Lecture 4 |