What will be the output of the program?
#include<stdio.h>

int main()
{
    int y=128;
    const int x=y;
    printf("%d", x);
    return 0;
}

128
Garbage value
Error
0
Point out the error in the program.
#include<stdio.h>
#define MAX 128

int main()
{
    char mybuf[] = "Astiwz";
    char yourbuf[] = "QUIZ";
    char *const ptr = mybuf;
    *ptr = 'a';
    ptr = yourbuf;
    return 0;
}

Error: unknown pointer conversion
Error: cannot convert ptr const value
No error
None of above
What will be the output of the program?
#include<stdio.h>
#include<stdlib.h>

union employee
{
    char name[15];
    int age;
    float salary;
};
const union employee e1;

int main()
{
    strcpy(e1.name, "K");
    printf("%s %d %f", e1.name, e1.age, e1.salary);
    return 0;
}

Error: RValue required
Error: cannot convert from 'const int *' to 'int *const'
Error: LValue required in strcpy
No error
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", array[0], string[0]);
    return 0;
}

Error: unknown max in declaration/Constant expression required
Error: invalid array string
None of above
No error. It prints A A
What will be the output of the program?
#include<stdio.h>
int fun(int **ptr);

int main()
{
    int i=10;
    const int *ptr = &i;
    fun(&ptr);
    return 0;
}
int fun(int **ptr)
{
    int j = 223;
    int *temp = &j;
    printf("Before changing ptr = %5x", *ptr);
    const *ptr = temp;
    printf("After changing ptr = %5x", *ptr);
    return 0;
}

Address of i
Address of j
10
223
Error: cannot convert parameter 1 from 'const int **' to 'int **'
Garbage value
Point out the error in the program.
#include<stdio.h>
#include<stdlib.h>

union employee
{
    char name[15];
    int age;
    float salary;
};
const union employee e1;

int main()
{
    strcpy(e1.name, "K");
    printf("%s", e1.name);    
    e1.age=85;
    printf("%d", e1.age);
    printf("%f", e1.salary);
    return 0;
}

Error: RValue required
Error: cannot modify const object
Error: LValue required in strcpy
No error
What will be the output of the program?
#include<stdio.h>

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

5
10
Error
Garbage value
Point out the error in the program.
#include<stdio.h>
const char *fun();

int main()
{
    char *ptr = fun();
    return 0;
}
const char *fun()
{
    return "Hello";
}

Error: Lvalue required
Error: cannot convert 'const char *' to 'char *'.
No error and No output
None of above
What will be the output of the program in TurboC?
#include<stdio.h>
int fun(int **ptr);

int main()
{
    int i=10, j=20;
    const int *ptr = &i;
    printf(" i = %5X", ptr);
    printf(" ptr = %d", *ptr);
    ptr = &j;
    printf(" j = %5X", ptr);
    printf(" ptr = %d", *ptr);
    return 0;
}

i= FFE2 ptr=12 j=FFE4 ptr=24
i= FFE4 ptr=10 j=FFE2 ptr=20
i= FFE0 ptr=20 j=FFE1 ptr=30
Garbage value
Point out the error in the program.
#include<stdio.h>

int main()
{
    const int x;
    x=128;
    printf("%d", x);
    return 0;
}

Error: unknown data type const int
Error: const variable have been initialised when declared.
Error: stack overflow in x
No error
What will be the output of the program?
#include<stdio.h>

int main()
{
    const char *s = "";
    char str[] = "Hello";
    s = str;
    while(*s)
        printf("%c", *s++);

    return 0;
}

Error
H
Hello
Hel
Point out the error in the program.
#include<stdio.h>

int main()
{
    const int k=7;
    int *const q=&k;
    printf("%d", *q);
    return 0;
}

Error: RValue required
Error: Lvalue required
Error: cannot convert from 'const int *' to 'int *const'
No error
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;
}

Garbage value
Error
20
0
Point out the error in the program.
#include<stdio.h>
#define MAX 128

int main()
{
    char mybuf[] = "Astiwz";
    char yourbuf[] = "QUIZ";
    char const *ptr = mybuf;
    *ptr = 'a';
    ptr = yourbuf;
    return 0;
}

Error: cannot convert ptr const value
Error: unknown pointer conversion
No error
None of above
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("After modification arr[3] = %d", arr[3]);
    return 0;
}

Before modification arr[3] = 4
After modification arr[3] = 10
Error: cannot convert parameter 1 from const int * to int *
Error: Invalid parameter
Before modification arr[3] = 4
After modification arr[3] = 4
Point out the error in the program.
#include<stdio.h>
const char *fun();

int main()
{
    *fun() = 'A';
    return 0;
}
const char *fun()
{
    return "Hello";
}

Error: RValue required
Error: Lvalue required
Error: fun() returns a pointer const character which cannot be modified
No error
What will be the output of the program?
#include<stdio.h>

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

10
11
No output
Error: ++needs a value
What will be the output of the program?
#include<stdio.h>

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

Error
-11, 34
11, 34
None of these