Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

Increment and Decrement operator in c??

$
0
0

Please help me guys for ?? i am always confuse while i am facing a problem related to pre and post - increment & decrements operators in c ?? i know basic rule of pre and post increment but after this i am again facing problem to solve it .. foe example --

1.>

#include<stdio.h>
int main()
{
int x;
x=5;
printf("%d %d %d",++x + ++x + ++x);
return 0;
}

2.>

 #include<stdio.h>
    int main()
    {
    int x;
    x=5;
    printf("%d %d %d",x++ + x++ + x++);
    return 0;
    }

3.>

#include<stdio.h>
int main()
{
int x;
x=5;
printf("%d %d %d",++x , ++x , ++x);
return 0;
}

according to me its output will be 6 7 8 but it becomes 8 8 8 why ?? 4.>

#include<stdio.h>
int main()
{
int x;
x=5;
printf("%d %d %d",x++ , x++ , x++);
return 0;
}

according to me its output will be 5 6 7 but it becomes 7 6 5 why ??

Thank You guys.


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>