1.

Explain GETS() and PUTS() function with example.

Answer»

GETS( ): In ‘C’ scanf( ) is not capable of receiving a multiword string, therefore, names such as “Rajeev Sharma” would be unacceptable. The function collects a string of characters terminated by a new line, the standard input.

PUTS(): The function puts() can display only one string at a time. Puts copies the nullterminated string to the standard output. Also on display a string, unlike printf(), puts() places the cursor on the next line.

Example:

void main()
{
char name [20];
printf (“enter your name");
gets (name);
puts (“Good Morning !”);
puts (name);
}

Output:

Enter your name, Rajeev Sharma

Good Morning

Rajeev Sharma.



Discussion

No Comment Found