Page 36 - Modular_V1.1_Flipbook
P. 36
When you run the preceding code, it will show the output as shown below:
I am Kittu.
I am 14 years old.
I study in class 10.
Alternatively, you can use the endl manipulator to insert a line break.
cout<<”I am Kittu.”<<endl;
cout<<”I am 14 years old.”<<endl;
There are some other escape sequence characters available in C++. You will learn more about
escape sequence characters later in this chapter.
INPUT
The cin object is used to take input from the user through keyboard. This object is used in
conjunction with the extraction operator >> (two greater than signs). The extraction operator is
followed by the variable in which you want to store the input value. For example:
int rollno;
cin>>rollno;
The cin object holds the output screen open until you give any input. This means that the program
will wait for the user to enter some characters from the keyboard. You can also take the string
input from the user:
char s;
cin>>s;
But with cin object, you can only take one word as string input. It ignores the string after the
blank space. For example:
#include<iostream.h>
void main()
{
char name[100];
cout<<”Enter your name: “;
cin>>name;
cout<<”Welcome “<<name;
}
When you run the preceding code, you will get the output as shown:
Enter your name: Niharika Saxena
Welcome Niharika Saxena
ESCAPE SEQUENCE CHARACTERS
Escape sequence characters are used to represent certain special characters which cannot print
directly on the output screen. Following are some of the important escape sequence characters:
34 Touchpad MODULAR (Version 1.1)-X

