Print an Integer Value in C Last Updated : 26 May, 2023 Comments Improve Suggest changes Like Article Like Report Printing an Integer in C is one of the most basic tasks. Input and output of the elements are essential for taking input from the user and then giving the output to the user. Here we are going to take an integer as input from the user with the help of the scanf() function and print that integer with the help of the printf() function in C language. How to Read and Print an Integer Value in C1. Printing Integer values in C Approach: Store the integer value in the variableOfIntType x.Print this value using the printf() method. The printf() method, in C, prints the value passed as the parameter to it, on the console screen. Syntax: printf("%d", variableOfIntType); Below is the C program to print the integer value: C // C Program to Print // Integer value #include <stdio.h> // Driver code int main() { // Declaring integer int x = 5; // Printing values printf("Printing Integer value %d", x); return 0; } OutputPrinting Integer value 52. Reading Integer values in C Approach: The user enters an integer value when asked.This value is taken from the user with the help of the scanf() method. The scanf() method, in C, reads the value from the console as per the type specified. For an integer value, the X is replaced with the type int. The syntax of the scanf() method becomes as follows then: Syntax: scanf("%d", &variableOfIntType); Below is the C program to read integer values in C: C // C program to take an integer // as input and print it #include <stdio.h> // Driver code int main() { // Declare the variables int num; // Input the integer printf("Enter the integer: "); scanf("%d", &num); // Display the integer printf("Entered integer is: %d", num); return 0; } Output: Enter the integer: 10 Entered integer is: 10 Comment More infoAdvertise with us Next Article Print an Integer Value in C R RishabhPrabhu Follow Improve Article Tags : C Language Computer Science Fundamentals C Basics Similar Reads Storage of integer and character values in C Integer and character variables are used so often in the programs, but how these values are actually stored in C are known to few. Below are a few examples to understand this: Taking a positive integer value as char: C #include <stdio.h> int main() { char a = 278; printf("%d", a); re 2 min read Return values of printf() and scanf() in C/C++ What values do the printf() and scanf() functions return ? printf() : It returns total number of Characters Printed, Or negative value if an output error or an encoding error Example 1: The printf() function in the code written below returns 6. As 'CODING' contains 6 characters. CPP // C/C++ program 2 min read Integer literal in C/C++ (Prefixes and Suffixes) Integer literal is a type of literal for an integer whose value is directly represented in source code. For example, in the assignment statement x = 1, the string 1 is an integer literal indicating the value 1, while in the statement x = 0x10 the string 0x10 is an integer literal indicating the valu 4 min read Print a long int in C using putchar() only Write a C function print(n) that takes a long int number n as argument, and prints it on console. The only allowed library function is putchar(), no other function like itoa() or printf() is allowed. Use of loops is also not allowed. We strongly recommend to minimize the browser and try this yoursel 2 min read Octal literals in C When we initialize a value by putting '0' before a number, the number is treated as octal. For instance '10' is read as 10 but '010' is read as 8. Octal numbers are the numbers with base 8 and octal literals are used to represent the octal integer valuesExampleInput : 0101Output : 65Input : 01010Out 1 min read Literals in C In C, Literals are the constant values that are assigned to the variables. Literals represent fixed values that cannot be modified. Literals contain memory but they do not have references as variables. Generally, both terms, constants, and literals are used interchangeably. For example, âconst int = 4 min read gcvt() | Convert float value to string in C Here, we shall see how a float number (floating point value) can be converted to the string in C language. It is a library function defined in stdio.h header file. This function is used to convert a floating point number to string. Syntax : gcvt (float value, int ndigits, char * buf); float value : 2 min read puts() vs printf() for printing a string In C, both puts() and printf() functions are used for printing a string on the console and are defined in <stdio.h> header file. In this article, we will discuss the differences in the usage and behavior of both functions. puts() FunctionThe puts() function is used to write a string to the con 3 min read printf in C In C language, printf() function is used to print formatted output in many ways to the standard output stdout (which is generally the console screen).Example:C#include <stdio.h> int main() { // Using printf to print the text "Hi!" printf("Hi!"); return 0; }OutputHi!Explanation: In this program 5 min read Octal numbers in c There are some less known facts in C related to octal numbers. Let us look at the below example code first. Examples: C // program to show octal number interpretation #include <stdio.h> int main() { int x = 012; printf("%d", x); return 0; } Output: 10 Surprisingly the output is not 1 2 min read Like