a. Extra values are being ignored
b. Generates an error message
c. Size of Array is increased
d. Size is neglected when values are given
Tuesday, May 19, 2009
Tuesday, May 12, 2009
Which one of the following is printed when this code is executed
int x;
int z=0;
for( x=0; x<5; x++) { z++; if( x <3 ) continue; if( x>3 ) break;
z++;
}
printf(“%d\n”, z);
a Z=1
b. Z=6
c. Z=7
d. Z=9
e. Z=10
int z=0;
for( x=0; x<5; x++) { z++; if( x <3 ) continue; if( x>3 ) break;
z++;
}
printf(“%d\n”, z);
a Z=1
b. Z=6
c. Z=7
d. Z=9
e. Z=10
1. When the function below is called with a pointer to an open file that contains only three characters A, B and C which one of the following is printed
void listFile( FILE * fp )
{
int c;
while( c = fgetc(fp) != EOF )
{
printf(“%d”, c);
}
printf(“\n”);
}
a. ABC1
b. 1111
c. The characters AB followed by an infinite number of C characters
d. 6566671
e. 0001
{
int c;
while( c = fgetc(fp) != EOF )
{
printf(“%d”, c);
}
printf(“\n”);
}
a. ABC1
b. 1111
c. The characters AB followed by an infinite number of C characters
d. 6566671
e. 0001
Thursday, April 9, 2009
The first line of a source file contains the following line.The compiler warns about "struct x declared inside parameter list". What is the compiler worried about?
extern int f(struct x *);
For two structures to be compatible, they must not only have the same tag name but be defined in the same scope. A function prototype, however, introduces a new, nested scope for its parameters. Therefore, the structure tag x is defined in this narrow scope, which almost immediately disappears. No other struct x pointer in this translation unit can therefore be compatible with f's first parameter, so it will be impossible to call f correctly (at least, without drawing more warnings). The warning alluded to in the question is trying to tell you that you shouldn't mention struct tags for the first time in function prototypes.
(The warning message in the question is actually produced by gcc, and the message runs on for two more lines, explaining that the scope of the structure declared "is only this definition or declaration, which is probably not what you want.")
For two structures to be compatible, they must not only have the same tag name but be defined in the same scope. A function prototype, however, introduces a new, nested scope for its parameters. Therefore, the structure tag x is defined in this narrow scope, which almost immediately disappears. No other struct x pointer in this translation unit can therefore be compatible with f's first parameter, so it will be impossible to call f correctly (at least, without drawing more warnings). The warning alluded to in the question is trying to tell you that you shouldn't mention struct tags for the first time in function prototypes.
(The warning message in the question is actually produced by gcc, and the message runs on for two more lines, explaining that the scope of the structure declared "is only this definition or declaration, which is probably not what you want.")
What is output of following recusive main function call ?
main()
{
static int s=5;
s--;
printf("%d",s);
(s>3)?main():0;
}
Output: 43
{
static int s=5;
s--;
printf("%d",s);
(s>3)?main():0;
}
Output: 43
Subscribe to:
Posts (Atom)