what will be the output of the following program, justify?
#define TEST

int TEST getdata()
{
static i;
i+=10;
return i;

}

main()
{
int k;
k = getdata();
}


Answers were Sorted based on User's Feedback



what will be the output of the following program, justify? #define TEST int TEST getdata() { ..

Answer / rama krishna sidhartha

Since there is no output statement in this program there
output will not be displayed.

The output statement must be as follows :

printf("%d",k);

Then the output will be 10.

Is This Answer Correct ?    1 Yes 0 No

what will be the output of the following program, justify? #define TEST int TEST getdata() { ..

Answer / aditya

there is no print statement and hence there is no output.
If at all k is printed it will be 10.

Is This Answer Correct ?    0 Yes 0 No

what will be the output of the following program, justify? #define TEST int TEST getdata() { ..

Answer / rkr

The Static variable is initialized to zero
In the above program

static i; which is equivalent to static i = 0;
Next line i is incrementing by 10, then i value is 10.
return the value is 10

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More C Interview Questions

Write program to remove duplicate in an array?

0 Answers  


main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y); }

27 Answers   Advent Global Solutions, CitiGroup, Valeo Lighting Systems India Private Limited, Vishal Transformers, Wipro, Zencer,


Do pointers take up memory?

0 Answers  


#include<stdio.h> main(0 { printf("\n %d %d %d",sizeof(3),sizeof("3"),sizeof(3)); }

4 Answers   HCL,


What extern c means?

0 Answers  






There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?

0 Answers  


how can we print  hellow world programme without using semicolon

3 Answers  


What is "Duff's Device"?

0 Answers   Celstream,


Explain how do you list a file’s date and time?

0 Answers  


What is meant by int main ()?

0 Answers  


What are the different flags in C? And how they are useful? And give example for each in different consequences?

1 Answers  


What is a macro, and explain how do you use it?

0 Answers  


Categories