Search Placementyogi.com
 

Advanced C Console Input Output Objective Questions and Answers

  :: Topics ::

1

What is the output of the following program?

#include<stdio.h>
int main()
{
  char str[2];
  printf("\nEnter the string : ");
  gets(str);
  printf("%s\t%s",str,(str+5));
}
//Input:
//Enter the string : Hi Placement Yogi
A.

Hi

B.

Hi Placement Yogi acement Yogi

C.

Hi+garbage value

D.

segmentation fault at run time

See Answer & Explanation Lets Discuss
Correct answer is : B
Explanation

Whenever a program that uses "gets" is compiled, compiler raises a warning message saying "the gets function is dangerous and should not be used."

Because gets() doesn't do any kind of check while getting bytes from stdin and putting them somewhere.It may result in stack corruption.

In above question even though array size is 2 but gets() reads all and put into memory. So the correct answer is B.

 
 

Banner to LogicGuns.com

Hide Page Information

C Console Input Output Advanced Objective Questions and Answers for Written Round Interview

Here you can find C Console Input Output Advanced Objective Questions with answers and explanation. We have a vast collection of Objective Questions on Console Input Output Advanced in C that will help you a lot!

Why learn C Console Input Output Advanced ?

Console Input Output Advanced are an integral part of C and many Objective Questions in the written round are asked from this topic.In this section you can learn and practice C Console Input Output Advanced (Objective Questions with Answers) to improve your skills in order to face the interview and clear campus and off-campus selection of TCS, Infosys, Wipro etc.

Where can I get C Console Input Output Advanced Objective Questions and Answers with Explanation?

PlacementYogi provides you lots of fully solved C Console Input Output Advanced Objective Questions and answers with explanation. Fully solved examples with detailed answer description, explanation are given and it would be easy to understand.Though we do not have pdf file for C Console Input Output Advanced , We have quiz Objective Questions with answers to help you test yourself..

\n

Where can I get C Console Input Output Advanced Interview Objective Questions and Answers (objective type, multiple choice)?

Here you can find objective type C Console Input Output Advanced Objective Questions and answers for interview and entrance examination.Multiple Answers and true or false type Objective Questions are also provided.

How to solve C Console Input Output Advanced problems?

You can easily solve all kind of Objective Questions based on C Console Input Output Advanced by practicing the exercises (including shortcut Console Input Output Advanced to solve problems) given below.