Professional Documents
Culture Documents
PROGRAM 1
#include <iostream>
#include <conio.h>
void main()
{
int num, counter, total = 1;
cout << "Enter a number: ";
cin >> num;
cout << "The factorial of " << num << " is ";
for (int counter = 1; counter <= num; counter++)
total *= counter;
cout << total;
getch();
num total counter counter <=num
8 1 1 1 <=8 TRUE
1 2 2 <=8 TRUE
2 3 3<=8 TRUE
6 4 4 <=8 TRUE
24 5 5 <=8 TRUE
120 6 6 <=8 TRUE
720 7 7 <=8 TRUE
5040 8 8 <=8 TRUE
40320 9 9 <=8 FALSE
} OUTPUT:
Enter a number: 8
The factorial of 8 is 40320
PROGRAM 2
#include <iostream>
#include <conio.h>
void main()
{
int persons, int numSales;
cout << "Enter number of salespersons: ";
cin >> persons;
cout << "Enter number of sales per salesperson: ";
cin >> numSales;
for (int x = 1; x <= persons; x++)
{
Atutubo, Dexenie, 202011925, Tracing Activity 4