Printing Number (Integer) Variable in C Language

Printing integer variables in the C language is a fundamental concept that every programmer should know. In this blog post, we will explore the different ways to print integer variables in C, including the use of the printf function and format specifiers. Whether you are a beginner or an experienced programmer, this post will provide valuable insights and tips on how to effectively print integer variables in your C programs.

 


#include<stdio.h>


int main() {

    int num = 25;

printf("Number is %d\n", num);

return 0;

}


This is a simple C program that prints the value of an integer variable to the standard output. Here is an explanation of each line of the code:

  1. #include<stdio.h>: This line includes the stdio.h header file, which contains the declarations for the printf function used in the program.
  2. int main() {: This line defines the main function, which is the entry point of the program.
  3. int num = 25;: This line declares an integer variable named num and initializes it with the value 25.
  4. printf("Number is %d\n", num);: This line calls the printf function to print the string "Number is " followed by the value of the num variable, followed by a newline character (\n) to the standard output. The %d format specifier is used to print the value of the num variable as an integer.
  5. return 0;: This line returns 0 from the main function, indicating that the program has executed successfully.
  6. }: This line marks the end of the main function.

 

My YouTube Channel ::

Thanks for visiting my Blog. Hopefully it helped you. Please check out more blogs for practice.
We will meet soon. bye. Jay Hind...

Comments

Popular posts from this blog

Exploring Pascal's Triangle in C: A Code Breakdown