hi, my name is vic...i got one problem cannot fix....output for the number of times each of the tasks has been invoked...i run 3 times each of the tasks but the output always is this program has run 1 times.....
#include<stdio.h>
#include<stdlib.h>
void doTaskA(){
printf("Start of Task A\n\n");
int input_1, input_2, input_3;
printf("Start of TASK A\n\n");
printf("Please enter 3 integer.\n");
scanf("%d\n%d\n%d",&input_1, &input_2, &input_3);
if ((input_3>input_1) && (input_3>input_2))
printf("/nThe biggest number is %d\n", input_3);
else if ((input_2>input_1) && (input_2>input_3))
printf("/nThe biggest number is %d\n", input_2);
else
printf("/nThe biggest number is %d\n",input_1);
}
void doTaskB(){
int row, c, n, temp;
printf("Start of Task B\n\n");
printf("Enter the number of rows in pyramid of stars you wish to see ");
scanf("%d",&n);
temp = n;
for ( row = 1 ; row <= n ; row++ )
{
for ( c = 1 ; c < temp ; c++ )
printf(" ");
temp--;
for ( c = 1 ; c <= 2*row - 1 ; c++ )
printf("*");
printf("\n");
}
}
void doTaskC(){
int n, c, k, space;
printf("Start of Task c\n\n");
scanf("%d", &n);
space = 0;
for ( k = n ; k >= 1 ; k-- )
{
for ( c = 1 ; c <= space ; c++ )
printf(" ");
space++;
for ( c = 1 ; c <= k ; c++)
printf("%d", c);
printf("\n");
}
}
void displayMenu(int &option) {
printf("\nPlease choose one of the following :");
printf("\n\n1. Task A\n");
printf("2. Task B\n");
printf("3. Task C\n");
printf("4. Task D ( Exit This Program )\n");
printf("\nPlease enter your selection :");
scanf("%d",&option);
}
void howMany(){
static int count = 0;
count++;
printf("This program has run" " %d " "times\n\n\n",count);
system("pause");
}
int main(){
int option =0;
bool exit = false;
while(!exit) {
displayMenu(option);
switch(option) {
case 1:
doTaskA();
continue;
case 2:
doTaskB();
continue;
case 3:
doTaskC();
continue;
case 4:
howMany();
exit = true;
break;
default:
printf("Incorrect selection. Try again.\n");
continue;
}
}
return 0;
}