C Programming Test

C Programming Test

 

Which of the following is not a valid mode for opening a file?

a. r
b. w
c. a
d. +
e. i


What will be the output of following code?

int main()
{
int i;
i = 0;
for (i = 1; i <2; i++)
{
i++;
printf( “%d”, i );
continue;
printf( “%d”, i );
}
return 0;
}

a. 22
b. 2,2
c. 2
d. none of the above


What would be printed on the standard output as a result of the following code snippet?

main()
{
int u = 1, v = 3;
printf(“%d %d”,u,v);
funct1(&u,&v);
printf(“%d %dn”,u,v);
}
void funct1(int *pu, int *pv)
{
*pu=0;
*pv=0;
return;
}

a. 1 31 3
b. 1 3 1 1
c. 1 30 0
d. 1 1 1 1
e. 3 1 3 1


What will be printed on the standard output as a result of the following code snippet?

void func()
{
static int i = 1;
int j = 1;
i++;
j++;
printf(“%d %d “,i,j);
}
void main()
{
func();
func();
func();
}

a. 2 2 2 2 2 2
b. 2 2 3 2 4 2
c. 2 2 2 3 2 4
d. 2 2 3 3 4 4
e. None of these


Identify the incorrect statement.

a. Records can be defined in C by using structures
b. Structure members can be of the same/different data types
c. Memory is reserved when a structure label is defined
d. A pointer to a structure can be used to pass a structure to a function
e. Arrays of structures can be defined and initialized


Which function will convert a string into an integer?

a. int()
b. number()
c. atoi()
d. val()
e. tonum()


Given the following array:

int a[8] = {1,2,3,4,5,6,7,0};

what would be the output of

printf(“%d”,a[4]); ?

a. 3
b. 4
c. 5
d. 6
e. 7


Prev1 of 7

Share This Post