Examveda
Examveda

What will be output if you will compile and execute the following c code?
#include<stdio.h>
#define max 5
void main(){
    int i = 0;
    i = max++;
    printf("%d", i++);
}

A. 5

B. 6

C. 7

D. 0

E. Compiler Error

Answer: Option E

Solution(By Examveda Team)

main.c: In function ‘main’:
main.c:5:12: error: lvalue required as increment operand
i = max++;

This Question Belongs to C Program >> C Preprocessor

Join The Discussion

Comments ( 5 )

  1. G Saravana
    G Saravana :
    6 years ago

    to see header file....statement missing

  2. Benito Paul
    Benito Paul :
    7 years ago

    oh great @ Tej Deep

  3. Umang Mahant
    Umang Mahant :
    7 years ago

    omg!!

  4. Tej Deep
    Tej Deep :
    7 years ago

    Error in the inclusion of header file will throw an error. Look carefully, after #include nothing is mentioned

  5. Nikhil Agarwal
    Nikhil Agarwal :
    8 years ago

    cause header file name missing

Related Questions on C Preprocessor