In this program, you will learn to get the input from user and display them on console. Here we have used scanf() and printf() functions. printf() and scanf() functions are inbuilt library functions in C programming language which are available in C library by default. These functions are declared and related macros are defined in “stdio.h” which is a header file in C language. We have to include “stdio.h” file as shown in below C program to make use of these printf() and scanf() library functions in C language. In C programming language, printf() function is used to print the (“character, string, float, integer, octal and hexadecimal values”) onto the output screen. We use printf() function with %d format specifier to display the value of an integer variable. Similarly %c is used to display character, %f for float variable, %s for string variable, %lf for double and %x for hexadecimal variable. To generate a newline, we use “ \n ” in C printf() statement. This function is declared and related macros are defined in “stdio.h” which is a header file in C language.
#include<stdio.h>
#include<conio.h>
void main()
{
int num1, num2;
clrscr();
printf("Enter 2 numbers: ");
scanf("%d%d", &num1, &num2);
printf("The numbers are %d %d",num1,num2);
getch();
}
Enter 2 numbers: 15 36
The numbers are 15 36