Possible Duplicate:
Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc…)
#include<stdio.h>
#include<conio.h>
#define SQ(x) x*x
void main()
{
int a1 , a2;
int b1 , b2;
a1 = 2;
a2 = 2;
b1 = 0;
b2 = 0;
b1 = SQ(a1++);
b2 = SQ(++a2);
printf("Frist = %d",b1);
printf("Second = %d",b2);
}
I know what is the output of the code.
as #define work in other programe that way it is not working in above code Why.?
C is a programming language that is both versatile and popular, allowing it to be used in a vast array of applications and technologies. It can, for example, be used to write the code for operating systems, complex programs and applications, and everything in between.
C is an imperative procedural language supporting structured programming, lexical variable scope, and recursion, with a static type system. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support.
Conclusion. In a nutshell, the main difference between C and C++ is that C is a procedural with no support for objects and classes, whereas C++ is a combination of procedural and object-oriented programming languages.
Python vs C Summary In brief, C is an older, compiled, low level, procedural programming language. It has more control over itself and the computer, and it runs faster. Python, on the other hand, is an interpreted, high level, and object oriented programming language that's easier to learn.
The result of an expression with more than one ++ operator on the same variable is officially an undefined behavior in C.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With