please help to me

Write a program in which the user is supposed to guess the number hidden in
the code. ( this will be an integer variable called “guess” and can be initialized
to any value between 0 and 100). If the number entered by the user is larger
than the hidden number, you should print, “You should try smaller values”.
Likewise if the number entered by the user is smaller than the hidden number,
you should print “You should try larger values”. If user enters the correct
number, you should print “Congratulations !!!” and exit the program. You
should print “Invalid, guess should be between 0 and 100” for guesses other
than [0-100]
Last edited on
have you tried it of your own ?
yes i did . i write much of them but,i dont know how to finish programme as pushing -1,
I'm guessing you use if... else if... else statements.
Just have the cases as follows:
if grade >= 91 && grade <=100
else if grade >= 81 && grade <=90
else if grade >= 71 && grade <=80
else if grade >= 61 && grade <=70
else if grade >= 0 && grade <=60
else if grade == -1
else 



Try this one:


#include <iostream>
using namespace std;

int main(){
int grade=0;
while (grade!=-1){
cout<<"Enter student grade: ";
cin>>grade;
if((grade>=91)&&(grade<=100))
cout<<"Letter grade is A"<<endl;
if((grade>=81)&&(grade<=90))
cout<<"Letter grade is B"<<endl;
if((grade>=71)&&(grade<=80))
cout<<"Letter grade is C"<<endl;
if((grade>=61)&&(grade<=70))
cout<<"Letter grade is D"<<endl;
if((grade>=0)&&(grade<=60))
cout<<"Letter grade is F"<<endl;
}
cout<<"Thanks for using my program.";
return 0;
}
Last edited on
Topic archived. No new replies allowed.