Monday
October 20, 2014

Homework Help: c++ program

Posted by kasey on Monday, October 24, 2011 at 12:18pm.

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

Answer this Question

First Name:
School Subject:
Answer:

Related Questions

Computer - on C++, I want to make an operation like " 2x + y - z ", I wrote ...
programming - Having trouble with this program running, can anybody help solve ...
computer sciece - #include <stdio.h> #include <stdlib.h> int main...
c++ program - will this work for a source code that receive and total collection...
C++ program - Create a source code that will prompt for recive and total a ...
C++ program - Create a source code that will prompt for recive and total a ...
computer - Which of the following does not print the numbers from I to 10? A) ...
C++ Programming - I have to redo programming exercise 5 of chapter 9 using ...
C Programming - I am trying to find the sum of two integers. I entered the ...
C programming - A few questions, all involving "for" loops that I am unsure how ...

Search
Members