A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C Program to Print an Integer entered by the user
Q:

C Program to Print an Integer entered by the user

belongs to collection: C programs - Basic C Programs

0

Write basic program in C language. It takes an integer as input from the user and displays it as output. Basically, this program illustrates the working of printf ans scanf function. This C program also demonstrates how integer variables are stored and accessed.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

C Program to Print an Integer entered by the user - Source code

#include <stdio.h>
 
int main()
{
    int number;
 
    printf("Enter an integer: ");
 
    scanf("%d", &number);
 
    printf("Integer entered by you: %d", number);
    return 0;
}

Program Output

Case 1:

Enter an integer: 590
Integer entered by you: 590


Case 2:

Enter an integer: 421
Integer entered by you: 421

Program Explanation

1. In this program an integer variable number is declared.

2. A message is displayed on the screen using printf function.

3. The integer entered by the user is stored in the variable number using scanf function.

4. At last, the stored integer is displayed on the screen using the printf function.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Program to Check if a given Number is Prime or n... >>
<< C program to multiply two floating point numbers...