Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
CPP All : Simple User Input
Concept Learning Code Sheets

Simple user input in integer form #1712

Learning the ways to take simple user input in integer form.

#include <iostream>
using namespace std;
int main()
{
int n;
cout<<"Enter an integer number: ";
cin>>n;
cout<<"You have entered "<<n<<endl;
return 0;
}

Multiple integer inputs without extraction chaining #1715

Taking more than one integer input without chaining of io extraction operator >>

#include <iostream>
using namespace std;
int main()
{
int a,b;
cout<<"Enter an integer number: ";
cin>>a;
cout<<"Enter another integer number: ";
cin>>b;
cout<<"Sum of two entries "<<a+b<<endl;
return 0;
}

Multiple integer entries with extraction operator chaining #1717

Way to enter multiple integer entries in one go using extraction operator chaining

#include <iostream>
using namespace std;
int main()
{
int a,b;
cout<<"Enter two integer numbers with a space in between: ";
cin>>a>>b;
cout<<"Sum of two entries "<<a+b<<endl;
return 0;
}

Input of different data types using cin #1719

Learning to input different data types using the standard console in object.

#include <iostream>
using namespace std;
int main()
{
char c;
int n;
float f;
cout<<"Enter a single character: ";
cin>>c;
cout<<"Enter an integer: ";
cin>>n;
cout<<"Enter a float number: ";
cin>>f;
cout<<endl<<"You entered "
<<c<<", "<<n<<", "<<f<<endl;
return 0;
}

Trying to input a string using cin #1721

Learning the behaviour of cin on c-style string (null terminated character arrays).

#include <iostream>
using namespace std;
int main()
{
char c[50];
cout<<"Input your name: ";
cin>>c;
cout<<endl<<"You entered "<<c<<endl;
return 0;
}

Anomaly of successive use of cin for char arrays #1726

Successive use of cin will pose some difficulty when used with char arrays or c-style strings.

#include <iostream>
using namespace std;
int main()
{
char c1[50];
char c2[50];
cout<<"Input a name: ";
cin>>c1;
cout<<"Input another name: ";
cin>>c2;
cout<<"You entered "<<c1<<" "<<c2<<endl;
return 0;
}

Input as char data and outputting as int data. #2310

A character data can be outputted as int data by typecasting.

#include <iostream>
using namespace std;
int main()
{
char ch;
cout<<"Input a character: ";
cin>>ch;
cout<<"ASCII of input character "<<(int)ch<<endl;
return 0;
}
Solved Problems

Converting input char to int and print ascii #2307

Write a c++ program to collect a single character from the user and print asc

Finding input variables errors #3190

Find error in the following program and suggest corrections. Assume that incl

Output writing implicit typecasting #3208

Write output of the following program if the input given is R

Quizzes

Code Sheets:7  Solved Problems:3  Quizzes:1
Back