The C Program given below is a Program to show several lines in C++ Programming. It's important to learn how to create a Line Break in C++ Programming. Suppose you want to show an address in the output. We all know the format of writing an address. We have to write several lines to represent an address. When we write it in Microsoft Office Word or in a Notepad Document then we may use Enter to create a new line. But in C++ Programming it's not possible. We have to use \n to create a new line where we want to create a line break. So you are going to learn about the \n command. Lets see the program given below...
#include<stdio.h>
void main()
{
printf("1.The First Line You Want to Show\n");
printf("2.The Second Line You Want to Show");
}
Output for the Above Codes
1.The First Line You Want to Show
2.The Second Line 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()
{
Commads you want to use
}
In the fourth line I have written printf("1.The First Line You Want to Show\n");. 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.
Look there is written printf("1.The First Line You Want to Show\n"); But in the screen you will see 1.The First Line You Want to Show only. \n won't be shown on the screen. \n is also a Command to create a new line in C++ Programming. For the command \n program will create a line break and the next part of the text will show in a new line. So the texts of the fifth line will show in a new line and the output will be...
1.The First Line You Want to Show
2.The Second Line You Want to Show
No comments:
Post a Comment