You are on page 1of 26

instruction : null question : What is the output of the code below?

# include "stdio.h"
main()
{
int size = 10;
int arr[size];
for ( i = 1 ; i <= size; i++)
{
scanf ("%d",&arr[i]);
printf ("\n%d", arr[i]);
}
}
answer : Compilation error
option : Runtime error
option : Garbage value
option : 10

question : What is the output of the code below?

# include "stdio.h"
main()
{
int i, j = 10, arrsize;
int arr[arrsize];
if ( j == 10)
arrsize = 20 ;
else
arrsize = 40 ;
for ( i = 0 ; i < arrsize; i++)
arr[i] = 100;
}
answer : Compilation error
option : Runtime error
option : 20
option : 40

question : What is the output of the code below


# include "stdio.h"
main()
{
int arr1[10],arr2[10], i ;
for ( i = 0 ; i <= 9 ; i++)
{ arr1[i] = 'A' + i ;
arr2[i] = 'a' + i ;
printf ("%d ", arr2[i]-arr1[i]);
}
}
option : Compilation error
option : Runtime error
answer : 32 32 32 32 32 32 32 32 32 32
option : 32 33 34 35 36 37 38 39 40 41
question : What is the output of the code below?
include "stdio.h"
main()
{
int b[] = {10,20,30,40,50} ;
int i ;
for ( i = 0 ; i <= 4 ; i++)
printf ("%d ", b[i]) ;
}
answer : 10 20 30 40 50
option : 1020304050
option : Compilation error
option : Runtime error

question : What is the output of the code below?

include "stdio.h"
main()
{
int Array[6] = {1,2,3,4,5,6} ;
int i ;
for ( i = 0 ; i <= 5 ; i++)
printf ("%d",Array[i]) ;
}
answer : 123456
option : 1 2 3 4 5 6
option : Compilation error
option : Garbage value

question : What is the output of the code below?

# include "stdio.h"
main()
{
int a[]={2,3,4,5,6} ;
int i ;
for ( i = 5 ; i > 0; )
printf ("%d ",a[--i]) ;
}
answer : 6 5 4 3 2
option : 65432
option : Compilation error
option : Runtime error

question : What is the output of the code below?

# include "stdio.h"
main()
{
int arr(25), i ;
for ( i = 0 ; t <= 100; t++)
{
arr(i) = 100;
printf ("%d",arr(i)) ;
}
}
option : 25
option : 100
answer : Compilation error
option : Runtime error

question : What is the output of the code below?

# include "stdio.h"
main()
{
int a[ ] = {10,20,30,40,50} ;
int j ;
for ( j = 0 ; j < 5; j++)
{
printf ("%d",*a) ;
a++;
}
}
option : 10 20 30 40 50
option : 1020304050
answer : Compilation error
option : Runtime error

question : What is the output of the code below?

# include "stdio.h"
main()
{
float a[ ] = {13.24,1.5,1.5, 5.4,3.5} ;
float *j, *k;
j=a;
k=a+4 ;
j=j*2;
k=k/2 ;
printf ("%f%f",*j,*k) ;
}
answer : Compilation error
option : Runtime error
option : 13.24 1.5 1.5 5.4 3.5
option : Garbage error

question : What is the output of the code below?


# include "stdio.h"
main()
{
int b[] = {10,20,30,40,50} ;
int i, *k;
k=&b[4]-4 ;
for ( i = 0 ; i <= 4 ; i++)
{
printf ("%d ",*k) ;
k++ ;
}
}
answer : 10 20 30 40 50
option : 1020304050
option : Compilation error
option : Runtime error

question : What is the output of the code below?


# include "stdio.h"
main()
{
int a[] = {2,4,6,8,10} ;
int i ;
for ( i = 0 ; i <= 4 ; i++)
{
*(a+i)=a[i ] + a[i];
printf ("%d ", *( i + a)) :
}
}
answer : 4 8 12 16 20
option : Garbage value
option : Runtime error
option : Compilation error

question : What is the output of the code below?

# include "stdio.h"
main()
{
int arr[] ={0,1,2,3,4} ;
int i, *ptr;
for (ptr = &arr[0]; ptr <= &arr[4]; ptr++)
printf ("%d ",*ptr) ;
}
answer : 0 1 2 3 4
option : 01234
option : Compilation error
option : Runtime error

question : What is the output of the code below?

# include "stdio.h"
main()
{
int arr[] ={0,1,2,3,4} ;
int i, *ptr;
for (ptr = &arr[0], i = 0 ; i <= 4 ; i++)
printf ("%d",ptr[i]) ;
}
option : 0 1 2 3 4
answer : 01234
option : Compilation error
option : Runtime error

question : What is the output of the code below?

# include "stdio.h"
main()
{
int arr[] = { 0,1,2,3,4} ;
int i, *p;
for (p = arr, i = 0 ; p + i <= arr + 4 ; p++, i++)
printf ("%d ",*(p + i)) ;
)
option : 0 1 2 3 4
answer : 0 2 4
option : 01234
option : 024

question : What is the output of the code below?

# include "stdio.h"
main()
{
int arr[] = {0,2,4,6,8} ;
int i, *ptr;
for (ptr = arr + 4 ; ptr <= arr; ptr--)
printf ("%d ",*ptr) ;
}
answer : 8 6 4 2 0
option : 86420
option : 0 2 4 6 8
option : 02468

question : What is the output of the code below?


# include "stdio.h"
main()
{
int arr[] = {0,2,4,6,8} ;
int i, *ptr;
for (ptr = arr + 4, i = 0 ; i <= 4 ; i++)
printf ("%d", ptr[-i]);
}
answer : 8 6 4 2 0
option : 86420
option : 02468
option : 0 2 4 6 8
question : # include "stdio.h"
# include "alloc.h"
# include "stdlib.h"
main()
{
char *sname ;
sname=(char *)malloc(5);
char fname[6]=("World");
sname=fname;
free(sname);
printf("%s",sname);
}
What id the output of the code above?
answer : World
option : garbage value
option : Compilation error
option : Runtime error

question : What is the output of the code below?

# include "stdio.h"
main()
{
float arr[] ={1.2,12,2.4,24,3.5,35} ;
int i ;
for ( i = 0 ; i <= 5; i++)
printf ("%.2f", arr[i]);
}
answer : 1.20 12.00 2.40 24.00 3.50 35.00
option : 1.2 12 2.4 24 3.5 35
option : Compilation error
option : Garbage value

question : What is the output of the code below?

# include "stdoi.h"
main()
{
static int a[]={2,3,4,5,6} ;
int i ;
for ( i = 5 ; i > 0; )
printf ("%d ",a[--i]) ;
}
option : 6 5 4 3 2
option : 65432
answer : Compilation error
option : Runtime error

question : What is the output of the code below?

# include "stdio.h"
main()
{
int n[25];
n[0] = 100;
n[24] = 200;
printf ("%d %d", *n, *(n + 24) + *( n + 0)) ;
}
answer : 100 300
option : 100 200
option : 200 300
option : Compilation error

question : # include "stdio.h"


# include "alloc.h"
# include "stdlib.h"
main()
{
char *sname ;
char fname[6]=("hello");
sname=fname;
free(sname);
printf("%s",sname);
}
What id the output of the code above?
answer : hello
option : garbage value
option : Compilation error
option : Runtime error

instruction : null

Module 5

question : What is the value of var after executing the following program

#include "stdio.h"
#define var 5
int main()
{
int *ptrx;
ptrx = &var;
*ptrx = 10;
printf("%d\n", var);
return 0;
}
option : 5
option : 10
answer : Compilation error
option : Rubtime error

question : . What is the value of x after executing the following program

#include "stdio.h"
int main()
{
int x=15;
int *ptrx;
ptrx = &x;
*ptrx = 20;
printf("%d\n", x);
return 0;
}
option : 15
answer : 20
option : Compilation error
option : Runtime error

question : Assume variable x is stored at memory location 100, y at memory 200, and ip at memory 300. What
will be the value of ip after executing the following statements?

int x, y, *ip; y=5;


ip=&x; option : ip = 300
answer : ip = 100
option : ip = 200
option : ip = 5

question : Assume variable x is stored at memory location 1000, y at memory 2000, and ip at memory 100. What
will be the value of y after executing the following statements?

int x, y, *ip;
x=5;y=10;
ip=&x;
y= *ip;
option : y =1000
answer : y = 5
option : y = 10
option : Runtime error

question : Assume variable x is stored at memory location 1000, y at memory 2000, and ip at memory 100. What
will be the value of y after executing the following statements?

int x, y, *ip;
x=5;y=10;
ip=&y;
y= *ip;
option : y=1000
option : y=5
answer : y=10
option : Runtime error

question : Assume variable x is stored at memory location 100, y at memory 200, and ip at memory 1000. What
will be the value of y after executing the following statements?

int x, y, *ip;
x=1;y=2;
ip=&x;
y= ip;
answer : y=100
option : y = 1
option : y=2
option : Runtime error

question : Assume variable x is stored at memory location 100, y at memory 200, and ip at memory 1000. What
will be the value of y after executing the following statements?

int x, y, *ip1,*ip2;
x=1;y=2;
ip1=&x;
ip2=&y;
y= ip2;
option : y=100
answer : y=200
option : y=1
option : y=2

question : Assume variable x is stored at memory location 100, y at memory 200, and ip at memory 1000. What
will be the value of y after executing the following statements?

int x, y, *ip1,*ip2;
x=10;y=2;
ip1=&x;
ip2=&y;
y= *ip1;
option : y=100
option : y=1000
option : y=200
answer : y=10

question : Assume variable x is stored at memory location 100, y at memory 200, and ip at memory 1000. What
will be the value of y after executing the following statements?

int x, y, *ip1,*ip2;
x=1;y=2;
ip1=&x;
ip2=&y;
y= ++(*ip2);
option : y=1
option : y=2
answer : y=3
option : y=100

question : What is the value of y after executing the following program?


#include "stdio.h"
main()
{
int count,y;
count = 20;
y = count > 10 ? 100:200;
printf("\ny=%i",y);
}
option : y=200
option : y=20
answer : y=100
option : y=10

question : # include "stdio.h"


# include "alloc.h"
# include "stdlib.h"
main()
{
char *sname ;
sname=(char *)malloc(5);
char fname[6]=("hello");
sname=fname;
free(sname);
printf("%s",fname);
}

What is the output of the code above?


answer : hello
option : Garbage value
option : Compilation error
option : Runtime error

question : # include "stdio.h"


# include "string.h"
# include "alloc.h"
main()
{
char *sname ="hello";
char fname[6];
strcpy(sname,fname);
printf("%s",sname);
}
option : hello
answer : Garbage value
option : Compilation error
option : Runtime error

question : . What is the value of x after executing the following program

#include "stdio.h"
int main()
{
int x=15;
int *ptrx;
ptrx = &x;
*ptrx = 20;
printf("%d\n", x);
return 0;
}
option : 15
answer : 20
option : Compilation error
option : Runtime error

question : Assume variable x is stored at memory location 1000, y at memory 2000, and ip at memory 3000.
What will be the value of ip after executing the following statements?

int x, y, *ip; y=2;


ip=&x;
option : ip = 3000
answer : ip = 1000
option : ip = 2000
option : ip = 2

question : Assume variable x is stored at memory location 100, y at memory 200, and ip at memory 1000. What
will be the value of y after executing the following statements?

int x, y, *ip;
x=1;y=2;
ip=&x;
y= *ip;
option : y =100
answer : y = 1
option : y = 2
option : Runtime error

question : Assume variable x is stored at memory location 100, y at memory 200, and ip at memory 1000. What
will be the value of y after executing the following statements?

int x, y, *ip;
x=1;y=2;
ip=&y;
y= *ip;
option : y=100
option : y=1
answer : y=2
option : Runtime error

question : Assume variable x is stored at memory location 100, y at memory 200, and ip at memory 1000. What
will be the value of y after executing the following statements?

int x, y, *ip;
x=1;y=2;
ip=&x;
y= ip;
answer : y=100
option : y = 1
option : y=2
option : Runtime error

question : Assume variable x is stored at memory location 100, y at memory 200, and ip at memory 1000. What
will be the value of y after executing the following statements?

int x, y, *ip1,*ip2;
x=1;y=2;
ip1=&x;
ip2=&y;
y= ip2;
option : y=100
answer : y=200
option : y=1
option : y=2

question : Assume variable x is stored at memory location 100, y at memory 200, and ip at memory 1000. What
will be the value of y after executing the following statements?

int x, y, *ip1,*ip2;
x=10;y=2;
ip1=&x;
ip2=&y;
y= *ip1;
option : y=100
option : y=1000
option : y=200
answer : y=10

question : Assume variable x is stored at memory location 100, y at memory 200, and ip at memory 1000. What
will be the value of y after executing the following statements?

int x, y, *ip1,*ip2;
x=1;y=2;
ip1=&x;
ip2=&y;
y= ++(*ip2);
option : y=1
option : y=2
answer : y=3
option : y=100

question : What is the value of y after executing the following program?


#include "stdio.h"
main()
{
int count,y;
count = 20;
y = count > 10 ? 100:200;
printf("\ny=%i",y);
}
option : y=200
option : y=20
answer : y=100
option : y=10

question : # include "stdio.h"


# include "alloc.h"
# include "stdlib.h"
main()
{
char *sname ;
sname=(char *)malloc(5);
char fname[6]=("hello");
sname=fname;
free(sname);
printf("%s",fname);
}

What is the output of the code above?


answer : hello
option : Garbage value
option : Compilation error
option : Runtime error

question : # include "stdio.h"


# include "string.h"
# include "alloc.h"
main()
{
char *sname ="hello";
char fname[6];
strcpy(sname,fname);
printf("%s",sname);
}
option : hello
answer : Garbage value
option : Compilation error
option : Runtime error

question : Which is not a valid operation on pointer ?


option : Relational Operator
option : Assignment Operator
option : Poniter Arithmetic
answer : Logical Operator

question : Which of the following is false about a pointer of type void* ?


option : It can be assigned pointer of any type
option : It must be casted to the newly assigned type
option : The value pointed to by void pointer is not valid
answer : The value pointed to by void pointer is valid
question : The concept of a pointer in programming to ...............
answer : effective usage of memory
option : effective usage of values
option : effective usage of time
option : effective usage of compiler

question : Memory allocated to pointer are taken from the .......


option : Global memory
option : main memory
answer : heap
option : registers

question : # include "stdio.h"


int b=9;
int *a = &b;
void *ptr;
main()
{
ptr = &b;
a=(int *) ptr;
printf("%d ", *a);
}
What is the output of the code above ? option : Compilation error
option : Runtime error
answer : 9
option : address of a

question : # include "stdio.h"


int b=9;
int *a = &b;
void *ptr;
main()
{

ptr = &b;
a=(char *) ptr;
printf("%d ", b);
}
What is the output of the code above ?
option : Address of a
option : 9
answer : compilation error
option : runtime error

question : # include "stdio.h"


int b=9;
int *a = &b;
void *ptr;
main()
{
ptr = &b;
a= ptr;
printf("%d ", *a);
}
What is the output of the code above ?
option : 9
option : Address of a
answer : Compilation error
option : Runtime error

question : # include "stdio.h"


int b=9;
int *a = &b;
void *ptr;
main()
{

ptr = &b;
a= ptr;
printf("%d ", b);
}

What is the output of the code above ?


option : 9
option : Address of a
answer : Compilation error
option : Runtime error

instruction : null

Module 6

instruction : null question : # include "stdio.h"


main()
{
printf(5+"olalekan");
}
answer : kan
option : 5olalekan
option : Compilation error
option : olale

question : # include "stdio.h"


main()
{ char st1[ ]="hello";
char st2[ ]= "hello";
if(st1==st2)puts("equal");
puts("unequal");
}
What is the output of the code above?
option : equal
answer : unequal
option : equal
unequal
option : compilation error

question : # include "stdio.h"


main()
{ char st1[ ]="hello";
char st2[ ]= "Hello";
if(st1==st2)puts("equal");
puts("unequal");
}
What is the output of the code above?
option : equal
option : unequal
answer : equal
unequal
option : compilation error

question : # include "stdio.h"


main()
{ char st1[ ]="hello";
char st2[ ]= "hello";
if(st1!=st2)puts("equal");
puts("unequal");
}
What is the output of the code above?
option : equal
option : unequal
answer : equal
unequal
option : compilation error

question : # include "stdio.h"


main()
{
char st[5]="hello";
printf("%s",st);
}

What is the output of the code above?


answer : compilation error
option : hello
option : garbage value
option : runtime error

question : # include "stdio.h"


main()
{
char st[6]="hello";
printf("%c",st);
}

What is the output of the code above?


answer : NO output
option : Compilation error
option : Runtime error
option : h

question : # include "stdio.h"


main()
{
char st[6]="hello";
printf("%c",*st);
}

What is the output of the code above?


option : hello
answer : h
option : Compilation error
option : Garbage vale

question : # include "stdio.h"


main()
{
char st[6]="hello";
printf("%s",*st);
}

What is the output of the code above?


option : h
option : hello
option : Compilation error
answer : Runtime error

question : # include "stdio.h"


# include "string.h"

main()
{
char fname[10], sname[10];
strcpy(fname,"BAyo");
strcpy(sname, "baYo");
printf("%s", memcpy(fname, sname,1));
}

What is the output of the code above?


option : bAyo
option : BAyo
option : baYO
answer : baYo
question : # include "stdio.h"
# include "string.h"

main()
{
char fname[10], sname[10];
strcpy(fname,"BAyo");
strcpy(sname, "baYo");
printf("%s", memcpy(fname, sname,2));
}

What is the output of the code above?


option : bayo
option : bAyo
option : BAyo
answer : baYo

question : What is the return type of strlen() fucntion ?


option : integer
answer : unsigned
option : long
option : memory address

question : What is the return type of strcat() function ?


option : int
option : short
option : long
answer : memory address

question : # include "stdio.h"


# include "string.h"

main()
{
char fname[10], sname[10];

strcpy(fname,"BAyo");
strcpy(sname, "baYo");
printf(" %d", strcmpi(fname, sname));

}
What is the output of the code above?
answer : 0
option : 1
option : -1
option : No output

question : # include "stdio.h"


# include "string.h"

main()
{
char fname[10], sname[10];

strcpy(fname,"BAyo");
strcpy(sname, "baYo");
printf(" %d", strcmp(fname, sname));

}
What is the output of the code above?
option : 0
option : 1
answer : -1
option : No output

question : # include "stdio.h"


# include "string.h"
# include "stdlib.h"
main()
{
char str[6] = "12pet";
char str1[6] = "paul";
char ch = 'e';
int x = atoi(str);
printf("%f",atof(str));

return 0;
}
What is the ouytput of the code above?
option : 12
answer : 12.000000
option : Compilation error
option : Garbage value

question : # include "stdio.h"


# include "string.h"
# include "stdlib.h"
main()
{
char str[6] = "12pet";
char str1[6] = "paul";
char ch = 'e';
printf("%s",strchr(str,ch));
return 0;
}
What is the output of the code above ?
answer : et
option : Compilation error
option : 12pet
option : 12p

question : # include "stdio.h"


# include "string.h"
# include "stdlib.h"
main()
{
char str[6] = "12pet";
char str1[6] = "paul";
char ch = 'e';
printf("%s",strset(str1,ch));
return 0;
}
What is the output of the code above ?
answer : eeee
option : paul
option : No output
option : Compilation error

question : .......... fucntion is used to clear the buffer attached to the standard input.

answer : fflush()
option : clear()
option : exit()
option : dump()

instruction : null

Module 7

instruction : null question : # include "stdio.h"


main()
{
struct employee {
char name[25];
int age;
float bs;
}
struct employee e ;
e.name = "Hacker" ;
e.age = 25 ;
print
f ("%s %d", e.name, e.age) ;
}

What is the ouitput of the code above?


answer : Compilation error
option : Runtime error
option : Hacker 25
option : Grabage Value

question : # include "stdio.h"


main()
{
struct
{
char name[25];
char language[10].
}a ;
static struct a = {"Hacker","C"};
printf ("%s %s", a.name, a.language) ;
}

What is the output of the code above?


answer : Compilation error
option : Runtime error
option : Hacker C
option : C Hacker

question : # include "stdio.h"


struct virus
{
char signature[25];
int size;
}v[2] ;
main()
{
static struct v[0] = {"Better by Far", 1975} ;
static struct v[1] = {"Naturally Ahead", 1970} ;
int i ;
for ( i = 0 ; i <= 1 ; i++)
printf ("%s %d\n", v[i].signature, v[i].size) ;
}

What is the output of the code above?


answer : Compilation error
option : Runtime error
option : Naturally Ahead 1970
option : Better by Far 1970

question : # include "stdio.h"


# include "string.h"
main()
{ struct
{
int num;
float f ;
char mess[50];
}m;
m.num = 1 ;
m.f = 314 ;
strcpy (m.mess, "Hello");
printf ("%d %.2f %s\n", m.num, m.f, m.mess);
}

What is the output of the code above?


option : Compilation error
option : Runtime error
answer : 1 314.00 Hello
option : Garbage value

question : # include "stdio.h"


# include "stdlib.h"
main()
{
struct node
{
int data;
struct node *link;
};
struct node*p,*q;
p = (node *)malloc (sizeof (struct node)) ;
q = (node *)malloc (sizeof (struct node)) ;
printf ("%d %d", sizeof (p) , sizeof (q)) ;
}

What is the output of the code above ?


answer : 4 4
option : Compilation error
option : Runtime error
option : 44

question : # include "stdio.h"


# include "stdlib.h"
main()
{
struct node
{
int data;
struct node *link;
};
struct node*p,*q;
p = (node *)malloc (sizeof (struct node)) ;
q = (node *)malloc (sizeof (struct node)) ;
printf ("%d ", sizeof (p) , sizeof (q)) ;
}
What is the output of the code above?
answer : 4
option : Compilation error
option : Runtime error
option : Garbage value

question : # include "stdio.h"


# include "stdlib.h"
main()
{
struct node
{
int data;
struct node *link;
};
struct node*p,*q;
p = (node *)malloc (sizeof (struct node)) ;
q = (node *)malloc (sizeof (struct node)) ;
printf ("%d %d", sizeof (p)) ;
}

What is the output of the code above?


option : 4
option : Compilation error
option : Runtime error
answer : Garbage value

question : # include "stdio.h"


# include "stdlib.h"
main()
{
struct node
{
int data;
struct node *link;
};
struct node*p,*q;
p = (node *)malloc (sizeof (struct node)) ;
q = (node *)malloc (sizeof (struct node)) ;
printf ("%d %x", sizeof (p) , sizeof (q)) ;
}

What is the output of the code above?


answer : 4 4
option : Compilation error
option : Runtime error
option : Garbage value

question : # include "stdio.h"


# include "stdlib.h"
main()
{
struct node
{
int data;
struct node *link;
};
struct node*p,*q;
p = (node *)malloc (sizeof (struct node)) ;
q = (node *)malloc (sizeof (struct node)) ;
printf ("%x %x", sizeof (p) , sizeof (q)) ;
}

What is the output of the code above?


answer : 4 4
option : Compilation error
option : Runtime error
option : Garbage value
question : # include "stdio.h"
# include "stdlib.h"
main()
{
struct node
{
int data;
struct node *link;
};
struct node*p,*q;
p = (node *)malloc (sizeof (struct node)) ;
q = (node *)malloc (sizeof (struct node)) ;
printf ("%X%x", sizeof (p) , sizeof (q)) ;
}

What is the output of the code above?


option : Compilation error
option : Runtime error
answer : 4 4
option : Garbage value

You might also like