Friday, 21 September 2018

Printing a String in C++ Programming

String

A string is a collection of characters which may be alphabets, numbers, symbols, and punctuation marks. E.g: $I am 21 years old$.

Write a program in C++ to print a string.


If we want to print a string directly into the output screen then this method is followed. The string is printed as per the choice of the programmer. The user can't alter this portion of the program on the output screen.

Program  


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<"12345.Welcome to the basic of C++\n";
cout<<"@*Thank you*@";
getch();
}


Output


The output of string printing
PRINTING A STRING







Explanation

In the above program, the keyword cout is used to print a string.

Syntax:
cout<<"  ";

Example:
cout<<"Whatever is written inside the double inverted comma(" ") is printed on the screen.";





No comments:

Post a Comment