HOW TO PRINT A VALUE IN C 

In C program we use printf keyword to display the output value.

       

                     // Simple Hello World program in C.

                    #include <stdio.h>

                    int main() 

                    {

                        // printf() is a output function which prints, the passed string in the output console.

                        printf("Hello, World!");

                        return 0;

                    }

            OUTPUT  → Hello, World! 

 

EXPLANATION ABOUT THE CODE

  • First, We have included a stdio.h header file, it enables us to use standard input/output functions in our C Program.
  • If we do not include the stdio.h header file in our program, we can not use input / output functions like printf() and scanf().
  • main() function is the main block of code where the execution of our program begins.
  • Inside the main() function we have two statements, printf("Hello, World!") and return 0.
  • printf() function is used to display the string inside it into the output window.
  • printf("Hello, World!") will print Hello, World! (without quotes "") in the output window.
  • return 0 will return 0 to the operating system and shows that execution went successfully without any errors. This is the last statement of every program.
  • main() function is supposed to return a value to the OS and after returning some value, the program finishes its execution.

 

NOTE :- printf() function returns the length of the string passed into it for printing in the output console.