We know that C is the mother language of programming. It is a basic language in programming sector. The first program usually we all do is the printing hello world. That means printing something in the output console.So, I will go for the program not only for printing hello world but also for printing anything in the output console.
The program below:
#include<stdio.h>
main(){
printf("Hello World");
}
As the string Hello World is passed through printf function, the output will print a line containing Hello World on the console.
Output:
Hello World
Now, I am writing a C program which will produce a string "I am a student":
#include<stdio.h>
main(){
printf("I am a student");
}
Output:
I am a student
If we want to print more than one line ,using line break, we need to use escape sequence '\n' for new line printing.
Program:
#include<stdio.h>
main(){
printf("Hi Rahat\nHow are you?\nWhat are you doing?");
}
Output:
Hi Rahat
How are you?
What are you doing?
The above program can also be written like below:
#include<stdio.h>
main(){
printf("Hi Rahat\n");
printf("How are you?\n");
printf("What are you doing?\n");
}
The program below:
#include<stdio.h>
main(){
printf("Hello World");
}
As the string Hello World is passed through printf function, the output will print a line containing Hello World on the console.
Output:
Hello World
Now, I am writing a C program which will produce a string "I am a student":
#include<stdio.h>
main(){
printf("I am a student");
}
Output:
I am a student
If we want to print more than one line ,using line break, we need to use escape sequence '\n' for new line printing.
Program:
#include<stdio.h>
main(){
printf("Hi Rahat\nHow are you?\nWhat are you doing?");
}
Output:
Hi Rahat
How are you?
What are you doing?
The above program can also be written like below:
#include<stdio.h>
main(){
printf("Hi Rahat\n");
printf("How are you?\n");
printf("What are you doing?\n");
}
Comments
Post a Comment