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

suppose there are five integers write a program to find larger among them without using if- else

2 Answers  


Explain what is the difference between a string and an array?

0 Answers  


what is call by value and call by reference

4 Answers  


What are integer variable, floating-point variable and character variable?

0 Answers  


How can draw a box in cprogram without using graphics.h header file & using only one printf(); ?

4 Answers   NIIT,






What is difference between && and & in c?

0 Answers  


What is the difference between the local variable and global variable in c?

0 Answers  


Do you know what is the purpose of 'extern' keyword in a function declaration?

0 Answers  


write a program to find the given number is prime or not

2 Answers   Accenture, Vasutech,


write a program to display numbers from 1 to 10 and 10 to 1?

2 Answers  


This is a variation of the call_me function in the previous question:call_me (myvar)int *myvar;{ *myvar += 5; }The correct way to call this function from main() will be a) call_me(myvar) b) call_me(*myvar) c) call_me(&myvar) d) expanded memory

0 Answers  


HOW TO HANDLE EXCEPTIONS IN C

8 Answers  


Categories