C – Input/Output Functions

After reading this input/output functions topic, you will understand its theory and examples also you will able to use these functions in C programming.

C input/output functions used to accept data from the user or to display information on the screen. The two most commonly used Input/Output functions are printf() and scanf().

printf():

This function used as a formatted output statement and when written in programs, to display information on the screen. This function defined in stdio.h header file.

scanf():

This function used as a formatted input statement and when written in programs, to ask from user to input data. This function defined in stdio.h header file.

Program (1): To demonstrate Input/Output functions .

#include<stdio.h>
#include<conio.h>
void main(void)
{
int a,b,sum;
printf("Enter two numbers\n");   //for display data on screen
scanf("%d %d",&a,&b);                     //for accepting input from user
sum=a+b;
printf("Addition is %d\n",sum);
getch();
}

Output (1)

Enter two numbers
4
7
Addition is 11

Published by

Electrical Workbook

We provide tutoring in Electrical Engineering.

Leave a Reply

Your email address will not be published. Required fields are marked *