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

How to swap 3 numbers without using 4th variable?

5 Answers  


how to execute with out main in cprogram

15 Answers   Infosys,


What do you know about the use of bit field?

0 Answers  


main() { char ch='356'; Printf("%d",ch); } *OUTPUT*:- -18 *Why?*

1 Answers  


how many errors in c explain deply

0 Answers  






There are N egg baskets and the number of eggs in each basket is a known quantity. Two players take turns to remove these eggs from the baskets. On each turn, a player must remove at least one egg, and may remove any number of eggs provided they all belong to the same basket. The player picking the last egg(s) wins the game. If you are allowed to decide who is going to start first, what mathematical function would you use to decide so that you end up on the winning side?

8 Answers   Google,


What is the difference between typedef struct and struct?

0 Answers  


Explain what does the format %10.2 mean when included in a printf statement?

0 Answers  


How. To pass the entrance test

1 Answers   Tech Mahindra,


what is the difference between procedure oriented and object oriented progaming language

1 Answers  


Write a program in C for showing working of different logical operator in C. Your program should guide users with proper message/menu on the console.

3 Answers   HCL,


What is the difference between c &c++?

0 Answers  


Categories