In this C programming article we will learn to print integer in different way. We can print an integer using printf().
We will take the input from user using scanf() and then we can print that int by printf() in C programming.
Table of Contents
ToggleC program to print integer
#include <stdio.h>
int main(){
int x; // variable declaration
printf("Enter an integer here : ");
scanf("%d", &x); // taking input and store it to integer x
printf("\nYou have entered the integer %d\n", x); // printing integer
return 0;
}
Output of this print integer program
Print integer using loop in C
#include <stdio.h>
int main(){
int i; // variable declaration
for (i = 1; i <= 100; i++)
printf("%d ", i); // printing integers
return 0;
}
Output of this C program
C program to store an integer in a string and print
#include <stdio.h>
int main (){
char numbers[1000];
printf("Input a large integer here : ");
scanf("%s", numbers); // taking string inpute
printf("\nYou have entered the integer = %s\n", numbers); // printing
return 0;
}
See the output
You can print any integer using other methods too. So, try to write a program in your own.