Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
327 views
in Computer by (41.1k points)
closed by

Consider the following c code segment: 

int a, b, c = 0;

void prtFun(void);

main( ) 

static int a= 1; 

prtFun( );

 a+= 1; 

prtFun( )

printf("\n %d %d ",a, b); 

}

Void prtFun(void) 

static int a =2; 

int b=1; 

a+=++b; 

printf("\n %d %d ",a, b);

 }

What output will be generated by the given code segment if:

Line 1 is replaced by auto int a = 1; 

Line 2 is replaced by register int a = 2; 

1 Answer

+1 vote
by (44.6k points)
selected by
 
Best answer

Correct option is 

Static local variables: Scope is limited to function/block but life time is entire 51. program .

Automatic local variables: Storage allocated on function entry and automatically deleted or freed when the function is exited.

Register variables: Same as automatic variables except that the register variables will not have addresses Hence may not take t he address of a register variable.

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.

Categories

...