int main()
{
int x=10;
printf("%d",++x+x++<x+++x++);
return 0;
}
a. Error
b. 1
c. 24
d. 0
e. 46
Wednesday, May 27, 2009
Tuesday, May 26, 2009
State the output
#include
int a = 20;
void main()
{
fun1();
printf(" ");
fun1();
printf(" ");
fun1();
printf(" ");
}
fun1()
{
static int b = 10;
b++;
printf("%d", b++);
b=12;
printf(" ");
printf("%d", b++);
}
A 10 12 10 12 10 12
B 11 12 11 12 11 12
C 11 12 14 12 14 12
D Error "static variable re-assignment"
int a = 20;
void main()
{
fun1();
printf(" ");
fun1();
printf(" ");
fun1();
printf(" ");
}
fun1()
{
static int b = 10;
b++;
printf("%d", b++);
b=12;
printf(" ");
printf("%d", b++);
}
A 10 12 10 12 10 12
B 11 12 11 12 11 12
C 11 12 14 12 14 12
D Error "static variable re-assignment"
Tuesday, May 19, 2009
You have a program containing the following statements:
#define ARRAYSIZE 20
char str[ARRAYSIZE]="Test string";
strcat(str, 'z');
When you run the program, it produces a segmentation fault.
Referring to the above scenario, how do you resolve the problem?
Choice a : Use malloc to dynamically allocate memory, rather than using a fixed array.
Choice b : Change 'z' to 'z\0'
Choice c : Change ARRAYSIZE to 21.
Choice d : Change 'z' to "z"
Choice e : Change strcat to strncat and specify a size of 1.
char str[ARRAYSIZE]="Test string";
strcat(str, 'z');
When you run the program, it produces a segmentation fault.
Referring to the above scenario, how do you resolve the problem?
Choice a : Use malloc to dynamically allocate memory, rather than using a fixed array.
Choice b : Change 'z' to 'z\0'
Choice c : Change ARRAYSIZE to 21.
Choice d : Change 'z' to "z"
Choice e : Change strcat to strncat and specify a size of 1.
You are looping through a set of results from an SQL database query,
Looking for a specific sequence of entries. Once the sequence of entries is found, you want to stop the loop and continue the program at the statement following the loop
Given the scenario described above, which line of code do you use?
Choice a : if (strcmp (DBSequence, "SEQUENCE")==0) continue;
Choice b : if (strcmp (DBSequence, "SEQUENCE")=0) break;
Choice c : if (strcmp (DBSequence, "SEQUENCE")==0) break;
Choice d : if (strcmp (DBSequence, "SEQUENCE")==0) return 0;
Choice e : if (strcmp (DBSequence, "SEQUENCE")==0) exit;
Given the scenario described above, which line of code do you use?
Choice a : if (strcmp (DBSequence, "SEQUENCE")==0) continue;
Choice b : if (strcmp (DBSequence, "SEQUENCE")=0) break;
Choice c : if (strcmp (DBSequence, "SEQUENCE")==0) break;
Choice d : if (strcmp (DBSequence, "SEQUENCE")==0) return 0;
Choice e : if (strcmp (DBSequence, "SEQUENCE")==0) exit;
If the size of the array is less than the number of initializers then,
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
b. Generates an error message
c. Size of Array is increased
d. Size is neglected when values are given
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
Subscribe to:
Posts (Atom)