C Variable Declaration and Scope Questions

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
What is the expected output of the following program ?

#include <stdio.h> int num = 10; int main() { int num = num; printf("%d ", num); return 0; }

10

10

(null)

(null)

Garbage value

Garbage value

Compilation error.

Compilation error.

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 be the output of the following program ?

#include <stdio.h> extern int num; int main() { num = 10; printf("%d ", num); return 0; }

10

10

Garbage value.

Garbage value.

(null)

(null)

Compilation error.

Compilation error.

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

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
Select the correct output for the following code.

#include <stdio.h> extern int num = 0; int main() { num = 10; printf("%d ", num); return 0; }

10

10

(null)

(null)

Garbage value.

Garbage value.

Compilation error.

Compilation error.

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 output of the code below ?

#include <stdio.h> int main() { { int num = 10; } { printf("%d", num); } return 0; }

Compilation error.

Compilation error.

10

10

0

0

(null)

(null)

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 of the following program ?

#include <stdio.h> int main() { int a = 046; printf("%d", a); return 0; }

46

46

046

046

38

38

62

62

0

0

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

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
Betwixt x, y and z which has a larger scope in this program below ?
int x;
int main()
{
int y;
return 0;
}
int z;

x

x

y

y

z

z

All has the same scope.

All has the same scope.

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!"]