+ 1

Can someone help me complete this code? I want the user to input something and want my code to the appropriate output.

#include <iostream> using namespace std; void printSomething(int a) { cout<<a; } void printSomething(char a) { cout<<"please enter an integer!"; } int main() { printSomething(); return 0; }

19th Oct 2018, 7:50 AM
Frank
3 odpowiedzi
0
void printSomething(){ int input; cout <<"Enter a value :"; cin >> input; cout <<"\nEntered: " <<input <<endl; }
19th Oct 2018, 7:56 AM
Akib
Akib - avatar
0
Not what I am looking for! I want the program to accept both a int or char but if an integer is not entered i want to print "please enter an integer".
19th Oct 2018, 9:15 AM
Frank
0
Add if statement.. finish your course also.
20th Oct 2018, 7:09 AM
Akib
Akib - avatar