+ 1

How can create this??

i want that the program at first says "put a number", then if I put the wrong number, displays in the screen saying " wrong number" but if I put the valid number, shows "valid number". I have the base, but I don't know how to make that the program reads the number and say if is valid or not.

8th Jan 2018, 4:03 PM
Tiffany
Tiffany - avatar
4 Answers
+ 6
Probably something like this, in C++?? #include <iostream> using namespace std; int main() { int num = 0, correctNumber = 10; cout << "Put an integer: "; cin >> num; // Get input and save in num cout << num << endl; if (num == correctNumber) { cout << "Valid number!" << endl; } else { cout << "Wrong number!" << endl; } return 0; }
8th Jan 2018, 5:08 PM
Ipang
+ 4
@Tiffany you're welcome, oh and for future reference, a question related to code is better tagged with the language name, so others can briefly understand how to respond and what to suggest, next time don't forget to put the language in the tag : )
10th Jan 2018, 5:49 PM
Ipang
+ 3
In which language you are programing ?
8th Jan 2018, 4:06 PM
Ahmed Salem
+ 2
thank u so much! zorra if i didn't say the language
10th Jan 2018, 5:38 PM
Tiffany
Tiffany - avatar