C Input Output Question 3

Hello PrepSter,

If you find any errors in the quiz below kindly comment in the comment section and we will make it our priority to fix it.

Also if you have a better of the solution to the questions, please do comment them below and if we find it better than ours, we will post it in our website.

Question 1

Time: 00:00:00
Choose the correct output for the following code.
#include<stdio.h>
int fun(char *str1)
{
char *str2 = str1;
while(*++str1);
return (str1-str2);
}
int main()
{
char *str = "PrepSter";
printf("%d", fun(str));
return 0;
}

 

16

16

6

6

4

4

8

8

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

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
What will finally be printed after the execution of the following program ?
#include <stdio.h>
int main()
{
int a =printf("abcd");
int b =printf("xyz");
printf("=%d",a+1*5,(b=a+10));
printf(" %d=",b);
return 0;
}

abcdxyz=5 11=

abcdxyz=5 11=

abcdxyz=9 14=

abcdxyz=9 14=

abcdxyz=9 19=

abcdxyz=9 19=

Error message because missing parenthesis.

Error message because missing parenthesis.

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

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
Choose the correct out out of the following code.
# include <stdio.h> 
int main()
{
int i=0;
for(i=0; i<20; i++)
{
switch(i)
{
case 0:
i+=5;
case 1:
i+=2;
case 5:
i+=5;
default:
i+=6;
break;
}
printf("%d ", i);
}
}

5 10 14 18

5 10 14 18

5 11 16 21

5 11 16 21

18 25

18 25

18 24

18 24

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 the Code>
#include<stdio.h> 
int main()
{
unsigned int x = -1;
int y = ~0;
if(x == y)
printf("same");
else
printf("not same");
return 0;
}

same

same

not same

not same

Compliation error.

Compliation error.

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 will be the output of the code below ?
#include<stdio.h>
int main()
{
unsigned int i=65000;
while ( i++ != 0 );
printf("%d",i);
return 0;
}

2,147,483,647

2,147,483,647

0

0

1

1

(null)

(null)

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

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
Choose the correct option for the expected output of the C code below.
#include <stdio.h>

int main()
{
int i=0;
while ( +(+i--) != 0)
i-=i++;
printf("%d",i);
return 0;
}

1

1

0

0

-1

-1

(null)

(null)

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 code below ?
#include <stdio.h>
int main()
{
printf("%c ",122);
printf("%c ",89);
printf("%c ",64);
return 0;
}

z Y @

z Y @

Error message

Error message

(null)

(null)

122 89 64

122 89 64

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!"]
Hey ! Follow us on G+