Search Header Logo

Play with C

Authored by Computer India

Computers

University

Used 1+ times

Play with C
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

30 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

1. function g(int n)

{

If(n>0) return 1;

else return -1;

}

function f( int a, int b)

{

If(a>b) return g(b-a);

If(a<b) return g(a-b);

return 0;

}

If f(a,b) is called , what is returned ?

a)Always -1

b)1 if a>b, -1 if a<b, 0 otherwise

c)-1 if a>b, 1 if a<b, 0 otherwise

d)0 if a equals b, -1 otherwise

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

2. Assuming n > 2. What value does the following function compute for even n ?

int f(int n)

{

If( n equals 1) { return 1}

If(n equals 2) { return f(n-1) + n/2 }

return f(n-2) + n

}

a)1 +2 + 3 + 4 + …. +n

b)1 + (2+4+ 6+ 8+ …. +n)

c)1 + n/2 + (4 +6 + 8 + …. + n)

d)2 + 4 + 6 + 8 + ……. + n

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

3. What is the output of the following code?


int main()

{

int i = 0;

switch(i)

{

case 0 : i++;

case 1 : i+++2;

case 2 : ++i;

}

printf("%d",i++);

return 0;

}

a) 2

b) 3

c) 4

d) 5

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

4. What is the output of this program?


int main()

{


int a = 1, b = 0;

int c = a%2 ? a++ : a-- ? a=0 : ++b ? b = 2 : b++ ;

printf("%d", c);

return 0;

}

a) 1

b) 2

c) 3

d) 0

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

5. How can you write a[i][j][k][l] in equivalent pointer expression?

a) (((***(a+i)+j)+k)+l)

b) ((**(*(a+i)+j)+k)+l)

c) (*(*(*(a+i)+j)+k)+l)

d) *(*(*(*(a+i)+j)+k)+l)

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

6. What is the output of this program?


#include <stdio.h>

void test(char**);

int main()

{

char *argv[] = {"A", "B", "C", "D"};

test(argv);

return 0;

}


void test(char **p)

{

char *m;

m = (p+= sizeof(int))[-2];

printf("%s", m);

}

a) A

b) B

c) C

d) D

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

7. What will be the output of the program?


#include <stdio.h>

int main(void)

{

char p;

char buf[10]={1,2,3,4,5,6,9,8};

p=(buf+1)[5];

printf("%d",p);


return 0;

}

a. 5

b. 6

c. 9

d. None of the above

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers