TECHASHUS - BASIC HELLO WORLD PROGRAM IN C
C hello world program: c programming language code to print hello world. This program prints hello world, printf library function is used to display text on screen, '\n' places cursor on the beginning of next line, stdio.h header file contains declaration of printf function. The code will work on all operating systems may be its Linux, Mac or any other and compilers. To learn a programming language you must start writing programs in it and may be your first c code while learning programming.
CODE
//C hello world example #include <stdio.h> int main() { printf("Hello world\n"); return 0; }
OUTPUT:
Hello world
We may store "hello world" in a character array as a string constant and then print it.
#include <stdio.h> int main() { char string[] = "Hello World"; printf("%s\n", string); return 0; }
Using loop we can print "Hello World" a desired number of time or indefinitely.
#include <stdio.h> #define TRUE 1 int main() { while (TRUE) { printf("Hello World\n"); } return 0; }
No comments: