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

what is diff b/w huge & far & near pointer??

1 Answers   HCL,


What is the most efficient way to count the number of bits which are set in an integer?

0 Answers  


In which mode we open the file for read,write and append also in c ? a)W b)w+ c)r+ d)a

2 Answers   BitWise,


What is ponter?

0 Answers   TCS,


#include<stdio.h> main() { int a=1; int b=0; b=++a + ++a; printf("%d %d",a,b); }

7 Answers   Infosys,


5. distance conversion: Convert a distance from miles to kilometers .there are 5280 feets per mile,12 inches per foot .2.54 centimeters per inch and 100000centimeters per kilometer

4 Answers  


What is #define?

0 Answers  


Just came across this question, felt worth sharing, so here it is I want you to make a C/C++ program that for any positive integer n will print all the positive integers from 1 up to it and then back again! Let's say n=5 I want the program to print: 1 2 3 4 5 4 3 2 1. Too easy you say? Okay then... You can ONLY USE: 1 for loop 1 printf/cout statement 2 integers( i and n) and as many operations you want. NO if statements, NO ternary operators, NO tables, NO pointers, NO functions!

1 Answers  


Why isn't any of this standardized in c? Any real program has to do some of these things.

0 Answers  


sir i wanted to know how we wap in c to add numbers without using arithmetic operator in which digits are entered by user?

2 Answers  


write a programming in c language, 1 3 5 7 9 11

2 Answers   NIIT,


Can an array be an Ivalue?

0 Answers   EXL,


Categories