Clouds
Home
Tutorial of C language
Computer Language
Introduction to C
Programming in C
Structure of C program
Variable in C
Datatypes in C
Token in C
Operator in C
Precedence of C Operator
Assignment Operator in C
Logical Operator in C
Bitwise Operator in C
Ternary Operator in C
C Input Output
Pointers in C
Storage Classes of C
Control Structure of C
C Decision Making Statement
C Looping Statement
C Jumping Statement
C Function
Function Call By Value
Function Call By Reference
C Input Output Function
C Structure
Array in C
Union in C

'C' - Input and Output

Input

In any programming language input means to feed some data into program. This can be given in the form of file or from command line. C programming language provides a set of built-in functions to read given input and feed it to the program as per requirement.

Output

In any programming language output means to display some data on screen, printer or in any file. C programming language provides a set of built-in functions to output required data. Here we will discuss only one input function and one output function just to understand the meaning of input and output. printf() function This is one of the most frequently used functions in C for output.

Example:-

				#include 
				void main()
				{
				 Printf("Hello World..");
				}
				

Example:-

				#include 
				#include<conio.h>
				void main()
				{
				 	clrscr();
				 	printf("Hello World");
					getch();
				}
				

Example:-

				#include<stdio.h>
				#include<conio.h>
				void main()
				{
				 	int a;
				 	clrscr();
				 	a=5;
				 	printf("%d",a);
					getch();
				}
				

Example:-

				#include<stdio.h>
				#include<conio.h>
				void main()
				{
				 	int a=5;
				 	clrscr();
				 	printf("%d",a);
					getch();
				}
				

Note :- Here %d is being used to print an integer

Example:-

				#include<stdio.h>
				#include<conio.h>
				void main()
				{
					int dec = 5;
				 	char str[] = "abc";
				  	char ch = 's';
				  	float pi = 3.14;
				  	printf("%d %s %f %c\n", dec, str, pi,  ch);
				  	getch();
				}
				
Here %d is being used to print an integer, %s is being usedto print a string, %f is being used to print a float and %c is being used to print a character. scanf() function This is the function which can be used to to read an input from the command line. Try following program to understand scanf() function.
				#include<stdio.h>
				#include<conio.h>
				Void  main()
				{
				 	int a;
					scanf("%d",a);
					printf("%d",a)
					getch();
				}
				

Here %d is being used to read an integer value and we are passing &a to store the vale read input. Here &indicates the address of variavle a. This program will prompt you to enter a value. Whatever value you will enter at command prompt that will be output at the screen using printf() function. If you eneter a non-integer value then it will display an error message.
Pointers in C >>
Storage Classes of C >>
Control Structure of C >>
C Decision Making Statement >>
C Looping Statement >>


Home Clouds