Answer to Question #273222 in C for sthe

Question #273222

What will be the output of the following code segment?

void fun()

{

 static int i=10;

print ("%d", ++i);

}

int main ()

{

fun ();

fun();




1
Expert's answer
2021-11-29T18:40:52-0500

From the above code we can observe that there is an operator which is initiated i=10. And when fun() is getting call first time then it will print the value of I but here ++I will firstly increment the value by 1 meand it will print 11.

Now when it will be called second time then it will firstly do the increment and then it will print the value. So, it will print 12 in the second call.

#include<stdio.h>
void fun(){
    static int i=10;
    printf("%d \n",++i);
}
int main(){
fun();
fun();
return 0;
 }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS