c++ program

posted by .

how can a modfiy this source code to a menu.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

main()

{

char cYesNo = '\0';
int iResp1 = 0;
int iResp2 = 0;
int iResp3 = 0;
int iElaspedTime = 0;
int iCurrentTime = 0;
int iRandomNum = 0;
int i1 = 0;
int i2 = 0;
int i3 = 0;
int iCounter = 0;

srand(time(NULL));

printf("\nPlay a game of Concentration? (y or n):");
scanf("%c", &cYesNo);

if (cYesNo == 'y' || cYesNo == 'Y'){

i1 = rand() % 100;
i2 = rand() % 100;
i3 = rand() % 100;

printf("\nConcentrate on the next three numbers\n");
printf("\n%d\t%d\t%d\n" , i1, i2, i3);

iCurrentTime = time(NULL);

do {

iElaspedTime = time(NULL);
} while ( (iElaspedTime - iCurrentTime) < 3 ); //end do while loop

system("clear");

printf("\nEnter each # separted with one space: ");
scanf("%d%d%d", &iResp1, &iResp2, &iResp3);

if ( i1 == iResp1 && i2 == iResp2 && i3 == iResp3);
printf("\nCongratulations!\n");

} else

printf("\nSorry, correct numbers were %d%d%d\n" , i1, i2, i3);

}//end if

}//end main function

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. C Programming

    I am trying to find the sum of two integers. I entered the following program into the Visual Studio and it is telling me that there are errors. Can someone tell me where they are please?
  2. programming

    Having trouble with this program running, can anybody help solve my problem: #include <stdio.h> #include <stdlib.h> #include <string.h> void draw_x(int width, int height); int main(int argc, char *argv[]){ int width, …
  3. computer

    Which of the following does not print the numbers from I to 10?
  4. C++ program

    Create a source code that will prompt for recive and total a collection of payroll amounts entered at the terminal untill a sentinel amount of 999 is entered. Here is what i have so far i know not much but am not that great at this …
  5. C++ program

    Create a source code that will prompt for recive and total a collection of payroll amounts entered at the terminal untill a sentinel amount of 999 is entered. Here is what i have so far i know not much but am not that great at this …
  6. c++ program

    will this work for a source code that receive and total collection of payroll amounts entered at the terminal until 999 is reached. #include <stdio.h> #include <stdlib.h> main() { int num = 0; printf("Enter number (-999 …
  7. computer sciece

    #include <stdio.h> #include <stdlib.h> int main() { int num[100]={0}; int i,n=0; for(i=0; num[i] != EOF ; i++,n++) { scanf("%d",&num[i]); } printf("%d\n", i); while(i=0;i<n;i++) printf("%d ",num[i]); printf("\n"); system("pause"); …
  8. Computer

    on C++, I want to make an operation like " 2x + y - z ", I wrote something like that but I can' t get the result, where is my mistake?
  9. programming

    I have a general question. i was given a task to write a c code which gets an integer number as an input and prints the number of digits the number has. I have written a function that does it, but the problem is whenever the integer …
  10. programming

    I had to create a c code that gets a number, returns how many digits it has,the digits sum, the digits product, to check if the digits sum is equal to product if yes return "1" else return 0, and in the end write a program the prints …

More Similar Questions