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

Input/Output Function

C Support three types of Input/Output Function

Character Input/ Output function

  • getchar()
  • putchar()
  • getch()
  • putch()

    String Input / Output Function

  • gets()
  • puts()

    File Input / Output Function

  • fprintf()
  • fscanf()
  • getc()
  • putc()
  • fgetc()
  • fputc()
  • fgets()
  • fputs()

    String Library function

  • strlen()
  • strrev()
  • strcmp()
  • strcat()
  • strcat()

    Question1:- Write a Program Enter the character then print the same character.

    				#include<stdio.h>
    				#include<conio.h>
    				void main()
    				{
    				  	char x;
    				  	printf("Enter the Charecter: ");
    				  	x=getch();
    				  	printf("%c",x);
    				}
    				
    Note:- this character is not visible on the scrin.

    Question2:- Write a Program Enter the character then print the same character.

    				#include<stdio.h>
    				#include<conio.h>
    				void main()
    				{
    				  	Char  x;
    				  	printf("Enter the Charecter: ");
    				  	x=getche();
    				  	printf("%c",x);
    				}
    				

    Question2:- Write a Program Enter the character then print the same character.

    				#include<stdio.h>
    				#include<conio.h>
    				void main()
    				{
    					char x;
    				  	printf("Enter the Charecter: ");
    				  	x=getchar();
    				  	printf("%c",x);
    				}
    				

    write a program enter the string then print the length of String using Function.

    				#include<stdio.h>
    				#include<conio.h>
    				#include<string.h>
    				void main()
    				{
    				  	int i;
    				  	char str[20];
    				  	clrscr();
    				  	printf("\nEnter the string: ");
    				  	scanf("%s",&str);
    				  	i=strlen(str);
    				  	printf("\nThe length of the string is %d.",i);
    				  	getch();
    				}
    				

    write a program enter the string then print the reverse of String using function

    				void main()
    				{
    				  	int i;
    				  	char str[20];
    				  	clrscr();
    				  	printf("\nEnter the string: ");
    				  	scanf("%s",&str);
    				  	strrev(str);
    				  	printf("\nReverse of the string is %s.",str);
    				  	getch();
    				}
    				

    WAP enter two string then copy the 2nd String into 1st string.

    				void  main()
    				{
    				  	char str1[20],str2[20];
    				  	clrscr();
    				  	printf("\nEnter the 1st string: ");
    				  	scanf("%s",&str1);
    				  	printf("\nEnter the 2nd string: ");
    				  	scanf("%s",&str2);
    				  	strcpy(str1,str2);
    				  	printf("%s",str1);
    				  	getch();
    				}
    				

    WAP enter two string then concatenate the 1st & 2nd String.

    				#include<stdio.h>
    				#include<conio.h>
    				#include<string.h>
    				void main()
    				{
    				  	char str1[20],str2[20];
    				  	clrscr();
    				  	printf("\nEnter the 1st string: ");
    				  	scanf("%s",&str1);
    				  	printf("\nEnter the 2nd string: ");
    				  	scanf("%s",&str2);
    				  	strcat(str1,str2);
    				  	printf("%s",str1);
    				  	getch();
    				}
    				

    WAP enter two string then check wather the 1st & 2nd String are same or not

    				#include<stdio.h>
    				#include<conio.h>
    				#include<string.h>
    				void  main()
    				{
    				  	int i;
    				  	char str1[20],str2[20];
    				  	clrscr();
    				  	printf("\nEnter the 1st string: ");
    				  	scanf("%s",&str1);
    				  	printf("\nEnter the 2nd string: ");
    				  	scanf("%s",&str2);
    				  	i=strcmp(str1,str2);
    				  	if(i==0)
    				  	{
    				    	printf("Both string are same");
    				  	}
    				  	else
    				  	{
    				    	printf("Both string are Not same");
    				  	}
    					getch();
    				}
    				

    C Structure >>
    Array in C >>
    Union in C >>
    Computer Language >>
    Introduction to C >>


    Home Clouds