int main()
{
printf("HELLO WORLD\n"); //Display function printf() is used.
return 0; //returns the result.
}
- <stdio.h>= header file contains the declaration of the function.
- printf() = It is library function used to display text on the screen.
- '\n' = Places the cursor at the beginning of the next line .
HELLO WORLD
DISPLAY using character variables
int main()
{
char a,b,c,d,e,f,g; // Declaring variables
a = 'H'; // assigning values to the variables.
b = 'E';
c = 'L';
d = 'O';
e = 'W';
f = 'R';
g = 'D'; // assigning values to the variables.
printf("%c%c%c%c%c%c%c%c%c%c", a, b, c, c, d, e, d, f, c, g); //Displaying the output
return 0; // returns result
}
OUTPUT :
HELLOWORLD
DISPLAY using string (a character array).
int main()
{
char s1[ ] = "HELLO WORLD\t";
char s2[] = {'H','e','l','l','o','w','o','r','l','d'}; //Declaration of variables and assigning value to them.
printf("%s %s", s1, s2);//Displaying the output.
return 0; //returns result.
}
Output:
HELLO WORLD Helloworld
- \t = places the cursor 8 steps ahead.
0 Comments
If you have any doubts , Please let me know.