+ 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.
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;
}
+ 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 : )
+ 3
In which language you are programing ?
+ 2
thank u so much! zorra if i didn't say the language