/* 4. pelda: Az alabbi kis program C kifejezesekre, operatorokra ad peldat
*/

#include <stdio.h>
#include <conio.h>

main()
{
 int a,b,c,d,e;
 float p,r;
 clrscr();
 a = 32000; b = 30000; c = a+b;

 printf("a=32000, b=30000, a+b= %d miert nem 62000?? ",c);// nem jelez hibat!

 a = 7; b = 2; c = a/b;

 printf("\nA / egeszek eseten egeszosztas! Pl. a=7, b=2, c= a/b = %d",c);

 a = b = 9;

 printf("\nTobbszoros ertekadas lehetseges: a=b=9; a= %d lesz",a);

 printf("\nGyorsabb programot eredmenyeznek az ertekado operatorok:");
 printf("\n +=, -=, *=, /=, %=");

 a = 10; a = a + 3; printf("\n a = 10, a = a + 3; a = %d",a);
 a = 10; a += 3; printf("\n a = 10, a += 3; a = %d",a);
 a = 7; a = a * 2; printf("\n a = 7; a = a * 2; a = %d",a);
 a = 7; a *= 2; printf("\n a = 7; a *= 2; a = %d",a);

 printf("\n\nLepteto operatorok mellekhatassal birnak:");
 a = 5; b = 2;
 c = ++a * --b;
 printf("a =5; b = 2; c = ++a * --b");
 printf("\nEredmeny: a= %d, b= %d, c=%d",a, b, c);

 a = 5; b = 2;
 ++a; --b; c = a * b;
 printf("\nMegfelel ++a; --b; c = a * b utasitasoknak,");
 printf("\naz eredmeny:  a=%d, b=%d, c=%d lesz",a,b,c);

 a =3; b= 6; c = 10; c += ++a + b--;
 printf("\n\n a=3; b=6; c=10; c += ++a + b--");
 printf("\nEredmeny: a=%d; b=%d, c=%d",a,b,c);

 a =3; b =6; c = 10; ++a; c += (a+b); b--;
 printf("\nMegfelel a  ++a; c += (a+b); b--  utasitasoknak:");
 printf("\naz eredmeny: a=%d, b=%d, c=%d lesz", a, b, c);

 printf("\n\nLogikai kifejezesekben a relaciooperatorok magasabb");
 printf("\n precedenciajuak, mint az &&, || logikai muveletek!");
 printf("\n Ezert sok zarojelezes elmaradhat, lasd alabbi peldat:");
 c = (25+3 < 45 && 12 > 7);
 b = ( ( (25+3)<45 ) && ( 12>7 ) );
 printf("\n c = (25+3 < 45 && 12 > 7) es b = ( ( (25+3)<45 ) && ( 12>7 ) )");
 printf("\n egyenertekuek, c=%d, b=%d, igazak",c,b);

 getch();
}





