Increment and Decrement With Same (Increment or Decrement )Operator on same variable multiple times in C++
Confusing Increment and Decrement Operations in C/C++, Compiler Dependent Increment and Decrement Operators in C/C++. These Statements outputs on the bases of Turbo C3 Compiler.
For Pre Increment - Initial value + All increment (pre or post) put on the places of all pre increment.
For Post Increment - Initial value + 1 put on the places of all post increment
Note: Same for Decrement
#include<stdio.h>
#include<iostream.h>
#include<conio.h>
int a;
main()
{
clrscr();
int a=5;
//a=a++ + a++; // 6+6=12
//a=++a + ++a ; //7 + 7=14
//a=++a + a; //6 + 6=12
//a=a+ ++a; //6+6=12
//a=a + a++; //5+6=11
//a=a++ + a; //6 +5=11
//a=a++ + a++ + a++; //6+6+6=18
//a=a++ + a++ +a++ +a++; //6+6+6+6=24
//a=a++ + a++ + a++ + a; //6+6+6+5=23
//a=++a + ++a + ++a; //8+8+8=24
//a=++a + ++a + ++a + ++a; //9+9+9+9=36
//a=++a + ++a + ++a + a; //8 +8 +8+8=32
//a=++a + a++; //7 + 6=13
//a=++a + a++ + a++; //8 + 6 + 6=20
//a=++a + a++ + a++ + a++; //9+6+6+6=27
//a=++a + a++ + a++ + ++a; //9+6+6+9=30
//a= --a + a; //4+4=8
//a=a+ --a; //4+4=8
//a=a++ + --a; //5+4=9
//a=a++ + a--; //5 +5=10
//a=a++ + --a + --a; // 4+3+3=10
//a=a<6;
int b=2;
a=5 && 6;
a=5>3 && 5<3;
a= b++>3 && b++>2; //2>3 =0, b=3
cout<<a<<" "<<b;
getch();
}
No comments:
Post a Comment