Const

Q1:
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

ANS:A - Garbage value

Step 1: int get(); This is the function prototype for the funtion get(), it tells the compiler returns an integer value and accept no parameters. Step 2: const int x = get(); The constant variable x is declared as an integer data type and initialized with the value '20'. The function get() returns the value '20'. Step 3: printf('%d', x); It prints the value of the variable x. Hence the output of the program is '20'.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.