GATE CS Applied Course

c programing


1

int incr (int i) { static int count = 0; count = count + i; return (count); } main () { int i, j; for (i = 0; i <= 4; i++) j = incr (i); }

Answers

0

Sai Posted on Nov 16, 2019 06:40 PM

simply it is same as 4+3+2+1+0=10 since i=0.1.2.3.4

0

Sachin Vishaul Posted on May 21, 2020 02:16 PM

j = 10 (0+1+2+3+4); static int's scope is within the function block; but its lifetime is from the time its declared till the end of the program/ throughout the program. Think of static variables like variables which become invisible (i.e) static variable declarations become invisible after declaring, and when functions are called again these declarations are not seen/taken into account by the compiler eg:"recursion".

0

Sachin Vishaul Posted on May 21, 2020 02:16 PM

j=10

© 2023 - All rights are reserved- AAIC Technologies pvt ltd