14. write a program that calculates and displays the screen area 1 * 2 * 3 * ... * n (with npositive integers are entered from the keyboard). Check the entry requirements to ensure a positive integer n.
# include
using namespace std;
void main ()
{
int i, n, t = 1;
cout << "Enter n =";
cin >> n;
while (n <0)
{
cout << "Please enter hybrid n" << "\ n";
cout << "n =";
cin >> n;
}
for (i = 1; i <= n; i + +)
{
t * = i;
}
cout << "Analysis of the comparison is" << t << "\ n";
}
# include
using namespace std;
void main ()
{
int i, n, t = 1;
cout << "Enter n =";
cin >> n;
while (n <0)
{
cout << "Please enter hybrid n" << "\ n";
cout << "n =";
cin >> n;
}
for (i = 1; i <= n; i + +)
{
t * = i;
}
cout << "Analysis of the comparison is" << t << "\ n";
}

No comments:
Post a Comment
Thanks