Computer Science, asked by aishwaryasaravanan04, 10 months ago

What is the output of the following code snippet?
#include main()
{
int const a=5;
a++;
printf("%d",a);
}

Answers

Answered by Dhanush2699
1

Answer: 5

Explanation:

It has post increment of variable 'a' so it will print 5 in the display...

Answered by gratefuljarette
0

Answer:

The output would be a compilation error.

Explanation:

The above code will throw the compilation error because in the above code we are trying to increment a constant variable which is not correct. We cannot modify a constant variable.

There are two types of increment operators in a programming language: Pre increment operator in which operator is used before the variable for example ++a. Post-increment operator in which the operator is used after the variable, for example, a+ +.

Similar questions