Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Plot the Code

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

#include<stdio.h>

int main()

{

int i = 1, j = 1;

..................................

{

printf("loop ");

}

return 0;

}

Output: loop loop loop loop loop

a)

for(--i ; i<10; i+=2)

b)

for(--i && j++ ; i<10; i+=2)

c)

for(++i && j-- ; i<10; i+=2)

d)

for(--i && j++ ; i<10; i-=2)

2.

#include<stdio.h>

int main()

{

static int i;

for(i++;++i;i++)

{

printf("%d ", i);

............................

}

return 0;

}


Output: 2 4 6

a)

if(i == 6)

break;

b)

if(i >=6)

break;

c)

if(i <= 6)

break;

d)

if(i != 6)

break;

3.

#include<stdio.h>

int main()

{

int fun = {

printf("C for loop ")

};

int x = 5;

............................

{

printf("%x ", x);

}

return 0;

}


Output:C for loop0 1 2 3 4 5 6 7 8 9 a

a)

for(x=0;x>=fun;x++)

b)

for(x=0;x<=fun;x--)

c)

for(x=0;x<=fun;x++)

d)

for(x=1;x<=fun;x++)

4.

#include<stdio.h>

int main()

{

char *str = "ZOHO";

while (*str)

{

putc(*str, stdout);

.......................................

printf("%c", *str);

str++;

}

return 0;

}


Output:ZZZOOOHHHOOO

a)

fputchar(*str);

b)

fputchar(**str);

c)

fputchar(*str*stdout);

d)

putchar(*str);

5.

#include<stdio.h>

void ptr(char**);

int main()

{

char *argv[] = { "abc", "def", "ghi", "jkl", "mno", "pqr" };

ptr(argv);

return 0;

}

void ptr(char **p)

{

char *t;

....................................

printf("%s\n", t);

}


Output: jkl

a)

t = (p += sizeof(int))[+1];

b)

t = (p += sizeof(int));

c)

t = (p += sizeof(int))[-1];

d)

t = (p = sizeof(int))[-1];

6.

#include<stdio.h>

int main()

{

int num = returns(sizeof(float));

..............................

return 0;

}

int returns(int returns)

{

returns += 5.01;

return(returns);

}


Output: 10

a)

printf("Value is %d", -num);

b)

printf("Value is %d", --num);

c)

printf("Value is %d", +num);

d)

printf("Value is %d", ++num);

7.

#include<stdio.h>

int function(int, int);

int main()

{

int a = 25, b = 24 + 1, c;

printf("%d", function(a, b));

return 0;

}

int function(int x, int y)

{

.......................

}


Output: 24

a)

return (x - (x == y));

b)

return (x - (x !=y));

c)

return (x +(x == y));

d)

return (x +(x != y));

8.

#include<stdio.h>

int main(){

int a = 36;

int *ptr;

ptr = &a;

.......................

return 0;

}


Output: Address Address

a)

printf("%u %u", *ptr ,&*ptr);

b)

printf("%u %u", *&ptr , &ptr);

c)

printf("%u %u", *ptr , *ptr);

d)

printf("%u %u", *&ptr , &*ptr);

9.

#include<stdio.h>

int main()

{

char s[] = {'a', 'b', 'c', '\n', 'c', '\0'};

char *p, *str, *str1;

p = &s[3];

str = p;

str1 = s;

........................

return 0;

}


Output: 77

a)

printf("%d", ++*p + +*str1-32);

b)

printf("%d", ++*p + ++*str1-32);

c)

printf("%d", +*p + ++*str1-32);

d)

printf("%d", ++*p + +str1-32);

10.

#include<stdio.h>

int main()

{

int arr[ ]={1.2, 2.4, 3.6, 4.8, 5};

int j, *ptr = arr;

.....................................

{

printf("%d ", *arr);

++ptr;

}

}


Output:1 1 1 1 1

a)

for(j >0;j<5;j++)

b)

for(j = 0;j<=5;j++)

c)

for(j = 0;j<5;j++)

d)

for(j = 1;j<5;j++)