76 851
Assignments Done
Successfully Done
In June 2019

Answer to Question #5458 in C++ for zuhaib abbasi

Question #5458
write a program in c++ that tell you if your input is a number or if it is not and print it on screen.
Expert's answer
#include <iostream>
#include <limits>

using namespace std;

int main() {
& int number = 0;
& cout << "Enter an integer: ";
& cin >> number;
& cin.ignore(numeric_limits<int>::max(), '\n');

& if (!cin || cin.gcount() != 1)
cout << "Not a numeric value.";
& else
cout << "Your entered number: " << number;
& return 0;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions