Showing posts with label AE.Gets and Puts function. Show all posts
Showing posts with label AE.Gets and Puts function. Show all posts

Gets function

it is used to get or scan string from user.it will terminate when user press Enter key.white space is also allowed in string.

SYNTAX: gets(variable); 

Example:
#include<stdio.h>
#include<conio.h>
main()
{
char name[100];
clrscr();
printf("Enter Your Name: ");
gets(name);
printf("\nYour name is %s",name);
getch();
}

Puts function

Puts function is used to display a string on any output devices.it is also used to print string stored in variable. Let us see syntax:

Syntax:
  
puts(variable);

Example for puts function:

#include<stdio.h>
#include<conio.h>
main()
{
     char string[100];
     clrscr();
     printf("Enter String: ");
     gets(string);
     printf("\nYour String was: ");
     puts(string);
     getch();

}