C Programming :: Basic Concepts

Home > C Programming > Basic Concepts > General Questions

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

41 / 87

 What will be output of the following "c" code?

#include
void main() {
int i = 400, j = 300;
printf("%d %d ");
}

AGarbage Values

Bstack overflow

C400 300

D300 400

Answer: Option A

Explanation:

In the printf() function we are just printing values, but it's not specified what values are we actually printing. Therefore, in such a case, it is going to print garbage values.

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

42 / 87

  What will be output of the following "c" code?

#include
void main()
{
printf("\n ab");
printf("\b si");
printf("\r ha");
}

Aha

Bab si ha

Cab ha

Dsi

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

43 / 87

 What will be output of the following "c" code?

#include
void main ( )
{
printf(5+"Hello world");
}

AHello world

BHelo

Cworld

DCompilation Error

Answer: Option C

Explanation:

It will print the characters starting from the 5th index(i.e, starting from the blank space) to the character present at (n-1)th index, or 10th index(i.e, ending at d).

Hence, the output will be  world.

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

44 / 87

 What will be output of the following "c" code?

#include
void main ( )
{
printf("\n Hello");
printf("\b world");
printf("\r Cup");
}

AHello

BHello World

CCup

Dworld

Answer: Option C

Explanation:

If line 4 gets executed alone, it will print Hello on the screen.

If line 4 and 5 gets executed, it will print Hell world on the screen, due to '\b'.

Now, when line 4, 5 and 6 gets executed, it will print Cupl world on the screen, due to '\r' the control goes to the starting point and re-writes Hel with Cup.

So, the correct answer will be Cupl world

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

45 / 87

 The following program fragment will give a
void main()
{
int sum, index,
-index= 50;
while (index > = 0) {
sum = sum / index;
-index;
} }

ARun time error

Bcompilation error

CLinking error

DNone of these

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

46 / 87

 The following lines, if included in a program, will cause which of the following errors?

double c;
scanf("%c",c);

ARuntime error:

BCompilation error

CTypedef error

DNo error

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

47 / 87

 What would be the values assigned to a, b, c, if the statement scanf("%d %d %d", &a, &b, &c) is extended with input data item 123466 ?

Aa = 12, b = 34, c = 56

Ba = 1, b = 2, c = 3

Ca=123456 and nothing is assigned to b and c

Da and b are not assigned anything, c = 123456

Answer: Option A

Explanation:

Option C will be the correct option, but the input we are giving is 123466, so value of a= 123466 and not a=123456. Also, nothing will be assigned to b and c.

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

48 / 87

 What would be the value assigned to a,b and c if the statement scanf ("%3d,%3d,%3d", &a,&b,&c) is executed with input data as 1234_5678_9 (Note: _ denote as blank)

Aa=123,b=4,c=567

Ba=123,b=567,c=9

Ca=123,b=456,c=789

Da=1234,b=5678,c=9

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

49 / 87

 What will be the output of the following C program?

void main()
{
int i= 1234; j = 0177, k = 0xa08c;
printf ("%8d %80x /n", I,j,k),
}

A12341777 a08c

B12341 abc a08c

C00001234 01aa ax

D12340777 ao80

Answer: Option A

Explanation:

The output will be an error, since variables 'j' and 'k' are not declared.

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

50 / 87

 The conditional compilation

AIt is taken care of by the compiler

BIt is setting the compiler option conditionally

CIt is compiling a program based on a condition

Dnone of above

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace