CSE Functions Quiz-2 PPC

Question 1

Time: 00:00:00
What is the output of the code given below ?

  1. #include<stdio.h>

  2. void loo(int n, int sum)

  3. {

  4. int d = 0, r = 0;

  5. if (n == 0)

  6. return;

  7. d = n % 10; r = n / 10;

  8. sum = sum + d;

  9. loo (r, sum);

  10. printf ("%d,", d);

  11. }

  12. int main ()

  13. {

  14. int num = 1998, sum = 0;

  15. loo (num, sum);

  16. printf ("%d ", sum);

  17. return 0;

  18. }

8,9,9,1,27

8,9,9,1,27

8,9,9,1,0

8,9,9,1,0

1,9,9,8,27

1,9,9,8,27

1,9,9,8,0

1,9,9,8,0

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
This code given below runs perfectly.

But what happens if we delete the code between //from here //to here ?
#include<stdio.h>
//from here
int fun (int);
//to here
int main()
{

int num2, num3;
num3 = fun(num2);
}

int fun(int num)
{
printf("Ye");
return num;
}

The code will be compiled and Ye will be printed.

The code will be compiled and Ye will be printed.

The code will be show warnings but ye will be printed.

The code will be show warnings but ye will be printed.

The code will not be compiled and nothing will be printed.

The code will not be compiled and nothing will be printed.

The code will show warnings and there will be unintended output.

The code will show warnings and there will be unintended output.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
What happens if the call the following program.

  1. void swap (int x, int y)

  2. {

  3. int temp;

  4. temp = x;

  5. x = y;

  6. y = temp;

  7. }

Function simply swaps number x and y for he main function.

Function simply swaps number x and y for he main function.

The number are swapped in this function but in main he numbers doesn't swap because there is no return type for the function swap.

The number are swapped in this function but in main he numbers doesn't swap because there is no return type for the function swap.

The number swapped inside this function but since hey are passed by value the value passed to the function swap doesn't change the value in main.

The number swapped inside this function but since hey are passed by value the value passed to the function swap doesn't change the value in main.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
What is the expected output of he following C code ?
#include<stdio.h>
int plus(int i)
{
static int fix = 0;
fix = fix + i;
return (fix);
}
void main()
{
int i,j;
for (i = 0; i <=4; i++)
j = plus(i);
printf("%d",j);
}

4

4

5

5

9

9

10

10

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
What is the expected output for he program below ?
#include <stdio.h>
int main()
{
printf("PrepInsta");
main();
return 0;
}

Compiler error.

Compiler error.

Infinite loop that prints PrepInsta.

Infinite loop that prints PrepInsta.

PrepInsta will be printed 2,147,483,647 times i.e the hight value of int .

PrepInsta will be printed 2,147,483,647 times i.e the hight value of int .

PrepInsta will be printed until there is a stack overflow.

PrepInsta will be printed until there is a stack overflow.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
Are these two function declaration similar ?

/* First function Declaration*/

int (*fun1)(int), (*fun2)(int);

/* Second function Declaration*/

typedef int (*fun)(int); fun fun1, fun2;

Yes, they are same.

Yes, they are same.

No, they are not same.

No, they are not same.

They are same but tydef is global therefore local function may not able o access it

They are same but tydef is global therefore local function may not able o access it

We can't have a typedef for a pointer to a function.

We can't have a typedef for a pointer to a function.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
What will be printed by the following program ?

  1. #include <stdio.h>

  2. void rep1 (int x, int y)

  3. {

  4. int z; z=x; x=y; y=z;

  5. }

  6. void rep2 (int *x, int *y)

  7. {

  8. int z; z=*x; *x=*y;*y=z;

  9. }

  10. int main()

  11. {

  12. int x=1, y=2, z=3; rep1(x, y); rep2(&y, &z);

  13. printf ("%d", z-x-y);

  14. return 0;

  15. }

-2

-2

1

1

2

2

-1

-1

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
What is the correct output of the following program ?

  1. #include<stdio.h>

  2. int fun(int val)

  3. {

  4. val=0;

  5. printf("%d",val);

  6. return 0;

  7. }

  8. int main()

  9. {

  10. fun;

  11. return 0;

  12. }

0 will be printed.

0 will be printed.

Some garbage value will be printed.

Some garbage value will be printed.

Nothing will be printed.

Nothing will be printed.

Compilation error.

Compilation error.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
What is the output of the following program ?

  1. #include <stdio.h>

  2. int dcr()

  3. {

  4. static int i = 22;

  5. return i--;

  6. }

  7. int main()

  8. {

  9. for(dcr(); dcr(); dcr())

  10. printf("%d ", dcr());

  11. return 0;

  12. }

19 16 13 10 7 4 1

19 16 13 10 7 4 1

20 20 20 20 20 infinite times.

20 20 20 20 20 infinite times.

22 18 14 10 6 4 2 0

22 18 14 10 6 4 2 0

21 18 15 12 9 6 3 0

21 18 15 12 9 6 3 0

20 17 14 11 8 5 2

20 17 14 11 8 5 2

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
Select the correct output of the following program.
#include <stdio.h>
int f1 (int a);
int f2 (int b);
void main()
{
int a = 10, b = 5, i;
for (i = 1; i <= 2; ++i)
{
b += f1(a) + f2(a);
printf ("%d ", b);
}
}

f1(int a)
{
int b;
b = f2(a);
return (b);
}

f2(int a)
{
static int b = 10;
b++;
return (b+a);
}

48 95

48 95

47 93

47 93

48

48

47

47

43 85

43 85

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Completed

0/0

Accuracy

0%