Q:
Write a C program to print Hello World
belongs to collection: C programming Basic Input, Output, if else, Ternary Operator based Programs
C programming Basic Input, Output, if else, Ternary Operator based Programs
- Write a C program to print Hello World
- Write a C program to find subtraction of two integer number
- Write a C program to find SUM and AVERAGE of two numbers
- Write a C program to print ASCII value of a character
- Write a C program to find cube of an integer number using two different methods
- Write a C program to find quotient and remainder
- Write a C program to calculate Simple Interest
- Write a C program to check whether a given number is EVEN or ODD
- Write a C program to find Largest Number among three numbers
- Write a C program to check whether a person is eligible for voting or not?
- Write a C program to read marks and print percentage and division
- Write a C program to calculate Gross Salary of an employee
- Write a C program to convert temperature from Fahrenheit to Celsius and Celsius to Fahrenheit
- Write a C program to calculate X^N (X to the power of N) using pow function
- Write a C program to find the difference of two numbers
- Write a C program to print size of variables using sizeof() operator
- Write a C program to demonstrate example of escape sequences
- Write a C program to find area and perimeter of circle
- Write a C program to find area of rectangle
- Write a C program to find HCF (Highest Common Factor) of two numbers
- Write a C program to multiply two numbers using plus operator
- Write a C program to demonstrate example of global and local scope
- Write a C program to demonstrate example of floor() and ceil() functions
- Write a C program to Read Formatted Time Once through Scanf in C Language
- Write a C program to How to define, modify and access a global variable
- Write a C program to convert feet to inches
- how to Print value in Decimal, Octal, Hexadecimal using printf in C
- Write a C program to Print ASCII value of entered character
- Write a C program to Print How Many Inputs are taken from Keyboard using Scanf in C program
- Write a C program to Calculate Employee and Employer Provident Fund using C program
- Write a C program to Set buffer with specific value using memset in C - Example of memset()
- Write a C program to evaluate the net salary of an employee given the following constraints
- How to swap two numbers without using a temporary variable using C program?
- Write a C program to read name and marital status of a girl and print her name with Miss or Mrs
- Write a C program to check given number is divisible by A and B
- Write a C program to find sum of all numbers from 0 to N without using loop
- Input hexadecimal value in C language
- Printing an address of a variable in C
- printf() statement within another printf() statement in C
- printf() examples/variations in C
- C program to calculate profit or loss
- Calculate the distance between two cities from kilometers to meters, centimeters, feet and inches using C program
- C program to find area and perimeter of the rectangle
- C program to generate random numbers within a range
- C Example to subtract two integers without using Minus (-) operator
- C Example for different floating point values prediction
- C Example for nested \"printf\"
- C program to find remainder of two numbers without using modulus (%) operator
- C program to convert ascii to integer (atoi() implementation)
- C program to print ASCII table/chart
- C program to swap two numbers using four different methods
- C program to check a given character is alphanumeric or not without using the library function
- C program to check a given character is a digit or not without using the library function
- C program to check a given character is a whitespace character or not without using the library function
- C program to check a given character is an uppercase character or not without using the library function
- C program to check a given character is a lowercase character or not without using the library function
- C program to check a given character is a punctuation mark or not without using the library function
- C program to check whether a character is a printable character or not without using library function
- C program to convert a lowercase character into uppercase without using library function
- C program to convert an uppercase character into lowercase without using library function
- C program to print all punctuation marks without using library function
- C program to print all punctuation marks using the ispunct() function
- C program to print all printable characters using the isprint() function
- C program to print all printable characters without using the library function
- C program to make a beep sound
- C program to convert a given number of days into days, weeks, and years
- C program to find the roots of a quadratic equation
- C program to find the GCD (Greatest Common Divisor) of two integers
- C program to find the LCM (Lowest Common Multiple) of two integers
- C program to calculate the area of a triangle given three sides
- C program to calculate the area of a triangle given base and height
- C program to calculate the area of Trapezium
- C program to calculate the area of the rhombus
- C program to calculate the area of Parallelogram
- C program to calculate the area of Cube
- C program to calculate the volume of Cube
- C program to find the Surface Area and Volume of the Cylinder
- C program to calculate the surface area, volume, and space diagonal of cuboids
- C program to calculate the surface area, volume of Cone
- C program to calculate the surface area, volume of the Sphere
- C program to calculate the mean, variance, and standard deviation of real numbers
- C program to read coordinate points and determine its quadrant
- C program to calculate the value of nCr
- C program to calculate the value of nPr
- C program to calculate the product of two binary numbers
- C program to calculate the addition of two complex numbers
- C program to extract the last two digits from a given year
- C program to perform the ATM Transactions
- C program to read the height of a person and the print person is taller, dwarf, or average height person
- C program to read the grade of student print equivalent description
Hello world/first program in C
Using function
Here, we are creating a user define function to print the text (“Hello World”) on the screen, read more about user define functions: C Library and User Define Functions (UDF), C user define functions programs
Output
Explanation
There is no other way to learn programming except writing programs. In every programming language we start programming by printing "Hello World" on the output device.
"Print Hello World in C" is the first program which we are writing here.
About the statements
1) #include <stdio.h>
stdio.h is a header file which contains declarations of standard input, output related functions, this statement tells to the compiler to include (add) the declarations of all standard input, output related functions which are declared inside stdio.h
2) int main()
main is a pre-declared function which is defined by the programmer i.e. the declaration of the main is predefine we can define its body.
main is the entry point from where program’s execution starts. While int is the return type of the main.
3) printf("Hello World!");
"Hello World!" is the sequence of characters it is called character array, string or constant string.
printf is a library function which is declared in stdio.h; this function is responsible to print the text on the output screen.
4) return 0;
This statement is returning the control of this program to the calling function (operating system’s thread which called this function) with value 0.
Return value 0 represents that the program’s execution completed successfully.
How to compile and run this program under various operating systems (or compilers)?
Write program in any text editor and save it with extension .c
Let’s consider the file name is "helloworld.c"
Under TurboC complier (Windows)
Open your saved program (or write program in the editor - use F2 to save it), to compile the program press ALT+F9, compiler will show all errors and warnings, if there is any error or/and warning correct it and compile again. If program is error and warning free you can run it by pressing CTRL+F9, after executing the program, press ALT+F5 to see the output of your program.
Under GCC Compiler (Linux)
To compile the program under GCC run the following command
Make sure you are in the current directory where program is saved (Learn Linux terminal commands)
If there is no errors or warnings object (binary) file helloworld will be created in the same directory now you can run program by using following command
need an explanation for this answer? contact us directly to get an explanation for this answer