LIVE Course for free

Rated by 1 million+ students
Get app now
0 votes
in Information Technology by (54.3k points)
closed by

What will be the output of the following?


int main()


int a = 5;


return 0;


1. A
2. 0
3. Abnormal termination of program
4. 5

1 Answer

0 votes
by (30.0k points)
selected by
Best answer
Correct Answer - Option 3 : Abnormal termination of program


  • In C, the scanf feature allows a programmer to accept input from a standard input device (keyboard) and store it in variables.
  • The scanf function is very similar to the printf function.
  • It reads data from the input device rather than printing it on the output device.
  • Each variable must be preceded by the ampersand (&) address-of operator in scanf function.


1) int a;

   scanf (" %d ", &a);

This will take the integer value and assign it to a, (No error).

2) int a;

   scanf (" %d ", a);

It will gave "Segmentation fault" 

It means accessing an invalid memory location, result in abnormal termination of the program.

Hence the option (3) is correct.

Related questions

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.