8escs01 problem solving through programming unit-2: c programming basics



Download 0,98 Mb.
bet12/22
Sana19.05.2023
Hajmi0,98 Mb.
#940862
1   ...   8   9   10   11   12   13   14   15   ...   22
Bog'liq
Module 2 c program

OPERATORS AND EXPRESSIONS


void main( )
{
int a, b, c; printf("Enter a, b, c: ");
scanf("%d %d %d", &a, &b, &c); if (a > b && a > c)
{ printf("a is Greater than b and c"); }
else if (b > a && b > c) { printf("b is Greater than a and c"); } else if (c > a && c > b) { printf("c is Greater than a and b"); } else { printf("all are equal or any two values are equal"); }
}
(C) LOGICAL OPERATORS - EXAMPLE
#include
Output:
Enter a, b, c: 3 5 8
c is greater than a and b

OPERATORS AND EXPRESSIONS


(D) ASSIGNMENT OPERATORS
  • It is used to assign the result of an expression to a variable.
  • The equal (=) sign is used as an assignment operator.

OPERATORS AND EXPRESSIONS


{
int Total=0, i; for(i=0; i<10; i++)
{
Total+= i; // This is same as Total = Total + i
}
printf(“Total = %d”, Total);
}
(D) ASSIGNMENT OPERATORS - EXAMPLE
# include int main( )
Output:
Total = 45

OPERATORS AND EXPRESSIONS

  • Syntax: Increment operator: ++var_name; (or) var_name++; Decrement operator: – -var_name; (or) var_name – -;

  • o Example: Increment operator : ++ i ; i ++ ; Decrement operator : - – i ; i – - ;

53
(E) INCREMENT & DECREMENT OPERATORS
  • Increment operators are used to increase the value of the variable by one and decrement operators are used to decrease the value of the variable by one in C programs.

OPERATORS AND EXPRESSIONS


{
int i = 1; while(i < 10)
{
printf("%d ", i); i++;
}
}
(E) INCREMENT & DECREMENT OPERATORS - EXAMPLE
#include void main()
Output:
1 2 3 4 5 6 7 8 9

OPERATORS AND EXPRESSIONS



Download 0,98 Mb.

Do'stlaringiz bilan baham:
1   ...   8   9   10   11   12   13   14   15   ...   22




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish