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

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

7 Answers   Infosys,


Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it?

3 Answers  


Do you know the difference between malloc() and calloc() function?

0 Answers  


extern static int i func() { i =10; i++; printf("%d \n",i); } main() { i =20; printf("%d \n",i); func(); printf("%d \n",i); }

2 Answers  


Write a c program using for loop in switch case?

1 Answers   Infosys,






What is pointer to pointer in c language?

0 Answers  


f() { int a=2; f1(a++); } f1(int c) { printf("%d", c); } c=?

7 Answers   Geometric Software,


what is the diff between the printf and sprintf functions?? and what is the syntax for this two functions ??

5 Answers  


Ca some one please help me with aC code to allow user enter numbers from 1 to 20 without repeating and prnt the sum of those numbers thnx

4 Answers  


main is a predefined or user define function if user defined why? if predefined whay?

12 Answers   TCS,


Write a program to show the workingof auto variable.

2 Answers   Infotech,


which of the following statements is incorrect a.typedef struct new{ int n1; char n2; } DATA; b.typedef struct { int n3; char *n4; }ICE; c.typedef union { int n5; float n6; } UDT; d.#typedef union { int n7; float n8; } TUDAT;

5 Answers   Assurgent, TCS,


Categories