C Programming :: Const / Volatile Qualifier

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

1 / 10

What is the output of the following 'C' program?

include
void main ()
{
const int x = get();
printf("%d", x);
}
get()
{
return (20);
}


A20

BError

CGarbage value

D0

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

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

2 / 10

What is the output of the following 'C' program ?

#include
void main ()
{
int y = 128;
const int x = y;
printf("%d", x);
}


A128

BError

CGarbage value

D0

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

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

3 / 10

What is the output of the following 'C' program?

#include
void main ()
{
const int x = 5;
int *ptrx;
ptrx = &x;
*ptrx = 10;
printf ("%d", x);
}


A5

B10

CError.

DGarbage value

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

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

4 / 10

What is the output of the following 'C' program ?

#include
void main ()
{
const int x = 5;
const int *ptrx;
ptrx = &x;
*ptrx = 10;
printf("%d", x);
}


A5

BCompilation Error

C10

DGarbage value

Answer: Option B

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

5 / 10

What is the output of the following 'C' program ?
#include <stdio.h>
#define SIZE 3 
void fun(int *ptr)
{
*ptr = *ptr + 1;
}
int main()
{
int oldval;
const int newval = 0;
static int temp = 99;
int i;
for (i=0;i< SIZE;i++)
{
oldval = newval; 
newval = i; 
fun(&temp);
}
printf("%d %d %d",oldval,newval,temp);
}

ACompilation error: assignment of read-only variable

B1 2 102

C1 3 103

DGarbage Value

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

6 / 10

What is the output of the following 'C' program ?
#include <stdio.h>
void fun1(void)
{
static int dummy = 5; 
dummy = dummy + 10; 
printf("%d",dummy);
}
void fun2(char *c)
{
*c = *c + 2;
printf("%d",dummy);
printf("%c", *c);
}
int main()
{
char ch = 'A'; 
fun1(); 
fun2(&ch); 
printf("%c", ch);
}

A15CC

B15CA

C155CC

DCompilation error: ‘dummy’ undeclared

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

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

7 / 10

Choose the correct option.

In a 'C' program, constant is defined


Abefore main

Bafter main

Canywhere, but starting on a new line

Dnone of these

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

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

8 / 10

For 'C' programming language


Aconstant expressions are evaluated at compile time

Bstring constants can be concatenated at compile time

Csize of array should be known at compile time

Dall of these

ENone of these

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

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

9 / 10

What is output or the error in the program?

#include

void main () {
const char* cptr = "Hello";
printf ("%c", (*++cptr)++);
}


Al-value specifies const object

BNo error, output is e

CNo error, output is H

DNo error, output is 1

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

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

10 / 10

What will be output of the following "c" code?
#include<stdio.h>
void main()
{
int const *p=5;
printf("%d", ++(p));
}

A9

B5

C6

D0

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace