1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include "stdAfx.h"
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
#include <Windows.h>
using namespace std;
int main ()
{
int origNumb;
cout << "This is a program that will take the number that you enter\n";
cout << "and multiply it, one at a time, by each number before it\n";
cout << "until it reaches 1.\n";
cout << "\n";
Sleep(4000);
cout << "Please enter a number: ";
cin >> origNumb;
int totalNumb = origNumb;
while (origNumb > 1)
{
origNumb -= 1;
totalNumb *= origNumb;
}
char letters[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
if (origNumb == letters[26])
{
cout << "You have not entered a number...";
Sleep(300);
cout << "Please enter a number: ";
}else
cout << "The answer is: ";
cout << totalNumb;
cout << "\n";
system ("PAUSE");
}
|