C Programming language

adplus-dvertising
C Programming Language: Input and Output Function
Previous Home Next

printf() Function

This is one of the most frequently used functions in C for output.

#include <stdio.h>
main()
{
	int num = 5;
	char str[] = "mini";
	char ch = 's';
	float pi = 3.14;
	printf("%d %s %f %c\n", num, str, pi, ch);
}

Scanf() Function

This is one of the most frequently used functions in C for intput.

#include <stdio.h>
main()
{
	int num ;
	char str[] = "mini";
	char ch = 's';
	float pi = 3.14;
	printf(“enter the value of num”);
	scanf(“%d”,&num); // take the value of num as input 
	printf("%d %c %f", num,str,pi); // print the values of num,str,pi,ch
}
Previous Home Next