Const

6

Point out the error in the program (in Turbo-C).

#include<stdio.h>
#define MAX 128

int main()
{
    const int max=128;
    char array[max];
    char string[MAX];
    array[0] = string[0] = 'A';
    printf("%c %c\n", array[0], string[0]);
    return 0;
}
A. Error: unknown max in declaration/Constant expression required
B. Error: invalid array string
C. None of above
D. No error. It prints A A

7

What will be the output of the program?

#include<stdio.h>

int main()
{
    const c = -11;
    const int d = 34;
    printf("%d, %d\n", c, d);
    return 0;
}

A. Error
B. -11, 34
C. 11, 34
D. None of these

8

What will be the output of the program?

#include<stdio.h>

int main()
{
    const int i=0;
    printf("%d\n", i++);
    return 0;
}
A. 10
B. 11
C. No output
D. Error: ++needs a value

9

What will be the output of the program (in Turbo C)?

#include<stdio.h>

int fun(int *f)
{
    *f = 10;
    return 0;
}
int main()
{
    const int arr[5] = {1, 2, 3, 4, 5};
    printf("Before modification arr[3] = %d", arr[3]);
    fun(&arr[3]);
    printf("\nAfter modification arr[3] = %d", arr[3]);
    return 0;
}
A.	Before modification arr[3] = 4 
        After modification arr[3] = 10

B.	Error: cannot convert parameter 1 from const int * to int *

C.	Error: Invalid parameter

D.	Before modification arr[3] = 4 
        After modification arr[3] = 4

10

What will be the output of the program?

#include<stdio.h>
int get();

int main()
{
    const int x = get();
    printf("%d", x);
    return 0;
}
int get()
{
    return 20;
}
A. Garbage value
B. Error
C. 20
D. 0