Sunday, March 31, 2013

Program to Show Your Text on the Screen in C++ Programming

C++ Program to Show Your Text

on the Screen

This is the first program to start C++ Programming. When you will go to start C++ Programming then most of the programmer will start the first class with this simple program. In this program you will learn the way to show your text in C++ Programming. We have to use printf command to show any text in output. In this program we will use printf to show our given text only. But printf may be used to show any result of the program also. For example you may input two numbers from keyboard and you may make a calculation of them, then you also need to use printf to show the result. Lets see the program given below...

#include<stdio.h>
void main()
{
printf("Provide the Text Here You Want to Show");
}

Output for the Above Codes:
Provide the Text Here You Want to Show

Code Description

In the first line I have written #include<stdio.h>. stdio.h is a Header File. So I have commanded the Computer to include the Header File stdio.h by the codes #include<stdio.h>. conio.h and math.h are also two Header files. If you want to add them then you have to write #include<conio.h> to include conio.h header file and #include<math.h> to add the math.h header file. When you need to add two or more header files in a program then you have to write like...

#include<stdio.h>
#include<conio.h>
#include<math.h>

In the Second Line I have written void main(). This is the main part of a C++ Program. You have to keep inside of void main() all of the command you want to use. The structure of void main() is given below.

void main()
{
Commands you want to use
}

In the fourth line I have written printf("Provide the Text Here You Want to Show");. Here printf is a command included in stdio.h header file. We have used this command to show some text in the output. The structure of printf is printf("Your Text");. That means you have to keep the text inside of the two double quotation (""). The program will show the text you will keep inside the Double Quotation. Though C++ does not support Capital Letter but you may use it here. That means you may write printf("YOUR TEXT"); if you want.

2 comments: