Hello World C
How to write a hello world in C language? To learn a programming language, you must start writing programs in it, and this could be your first C program. Let's see. Basic Program of C language.
#include <stdio.h> //Pre-processor directive
#include <conio.h>
How to write a hello world in C language? To learn a programming language, you must start writing programs in it, and this could be your first C program. Let's see. Basic Program of C language.
#include <stdio.h> //Pre-processor directive
#include <conio.h>
void main() //main function declaration
{
printf("Hello world\n"); //to output the string on a display
printf("Hello world\n"); //to output the string on a display
getch(); //terminating function
}
C hello world using character variables
#include <stdio.h>
#include <conio.h>
void main()
{
char a = 'H', b = 'e', c = 'l', d = 'o';
char e = 'w', f = 'r', g = 'd';
char a = 'H', b = 'e', c = 'l', d = 'o';
char e = 'w', f = 'r', g = 'd';
printf("%c%c%c%c%c %c%c%c%c%c", a, b, c, c, d, e, d, f, c, g);
getch();
}
}
We have used seven-character variables, '%c' is used to display a character variable. See other efficient ways below.
We store "hello world" in a string (a character array).
#include <stdio.h>
#include <conio.h>
void main()
{
char s1[] = "HELLO WORLD";
char s2[] = {'H','e','l','l','o',' ','w','o','r','l','d','\0'};
char s1[] = "HELLO WORLD";
char s2[] = {'H','e','l','l','o',' ','w','o','r','l','d','\0'};
printf("%s %s", s1, s2);
getch();
}
}
Output:
HELLO WORLD Hello world
If you Don't understand the program don't worry.
C Hello world a number of times
Using a loop we can display it a number of times.
Hello world in C indefinitely
#include <stdio.h>
#include <conio.h>
void main()
{
while (1) // This is always true, so the loop executes forever
puts("Hello World");
{
while (1) // This is always true, so the loop executes forever
puts("Hello World");
getch();
}
}
To terminate the program press (Ctrl + C)..
No comments:
Post a Comment