C Programming - Const - Discussion
Discussion Forum : Const - Find Output of Program (Q.No. 10)
10.
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;
}
Answer: Option
Explanation:
Step 1: const c = -11; The constant variable 'c' is declared and initialized to value "-11".
Step 2: const int d = 34; The constant variable 'd' is declared as an integer and initialized to value '34'.
Step 3: printf("%d, %d\n", c, d); The value of the variable 'c' and 'd' are printed.
Hence the output of the program is -11, 34
Discussion:
20 comments Page 2 of 2.
G Pavan Kumar said:
10 years ago
7 24 [Error] 'c' was not declared in this scope.
Shahrukh said:
1 decade ago
Ya it will take int as the default data type.
Sandeep said:
1 decade ago
It is giving error C does not name a type.
Chandradeep S said:
8 years ago
In GCC, its's printing some garbage value.
Nakul said:
8 years ago
Why only int and what is constant exactly?
Saravana kumar said:
8 years ago
In c++ shell compiler. It shows an error.
Dinesh said:
1 decade ago
What will be the data type of "c"?
Ram said:
9 years ago
How it will take int data type?
Madhusudan said:
1 decade ago
By default it takes int.
Soumya said:
1 decade ago
Thanks Sunil.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers