SarkariBix
SarkariBix
Start typing & press "Enter" or "ESC" to close
  • Home
  • Jobs
  • Results
  • Current Affairs
  • GK
  • Online Test
  • HR Interview
  • BLOG

What will be the output of the program? #include int main() { const int i=0; printf("%d\n", i++); return 0; }

  • Home
  • Computer Science & Engineering
  • C Programming Questions and Answers
  • Const
  • Discuss - 749
1. 

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

Answer: Option D

Explanation:

This program will show an error "Cannot modify a const object".

Step 1: const int i=0; The constant variable 'i' is declared as an integer and initialized with value of '0'(zero).

Step 2: printf("%d\n", i++); Here the variable 'i' is increemented by 1(one). This will create an error "Cannot modify a const object".

Because, we cannot modify a const variable.

Workspace Report
Leave a Comment

Computer Science & Engineering :: C Programming Questions and Answers : More Exercises

  • Declarations and Initializations
  • Expressions
  • Functions
  • Pointers
  • Strings
  • Input / Output
  • Bitwise Operators
  • Const
  • Variable Number of Arguments
  • Library Functions
  • Control Instructions
  • Floating Point Issues
  • C Preprocessor
  • Arrays
  • Structures, Unions, Enums
  • Command Line Arguments
  • Typedef
  • Memory Allocation
  • Complicated Declarations

Questions & Answers

Aptitude Chemical Engineering Civil Engineering Computer Science & Engineering Current Affairs Data Interpretation Electrical & Electronics Engineering Electronics & Communication Engineering General Knowledge Logical Reasoning Mechanical Engineering Non Verbal Reasoning Verbal Ability Verbal Reasoning

Interviews

HR Interview

Jobs

Sarkari Jobs

Results

Rojgar ResultSarkari Result

Admission

Admission 2022

Admit Card

Admit Card 2022

Answer Key

Answer Key 2022
copyright
Privacy Policy
© 2022 SarkariBix. All Rights Reserved.

Report