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



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

OPERATORS AND EXPRESSIONS


(H) SPECIAL OPERATORS
  • Below are some of special operators that C language.

#include void main( )
{ int a = 4; float b=6.7;
printf("Size of variable a = %d\n", sizeof(a) ); printf("Size of variable b = %f\n", sizeof(b) );
}
60
(H) SPECIAL OPERATORS - EXAMPLE
Output:
Size of variable a = 2 Size of variable b = 4

OPERATORS AND EXPRESSIONS


OPERATORS PRECEDENCE
  • Operator precedence determines the grouping of terms in an expression.
  • This affects how an expression is evaluated.
  • Certain operators have higher precedence than others.

OPERATORS AND EXPRESSIONS


OPERATORS PRECEDENCE - EXAMPLE
  • For example, the ‘*’ operator has higher precedence than the ‘+’ operator.
  • Example: x = 7 + 3 * 2;

  • Here, x is assigned 13, not 20 because operator * has higher precedence than +, so it first gets multiplied with 3*2 and then adds into 7.

OPERATORS PRECEDENCE - EXAMPLE


Program
/*Evaluation of expressions*/ main( )
{
float a, b, c, y, x, z; a = 9;
b = 12;
c = 3;
x = a – b / 3 + c * 2 – 1;
y = a – b / (3 + c) * (2 – 1);
z = a – (b / (3 + c) * 2) – 1;
printf(“x = %f \n”,x);
printf(“y = %f \n”,y);
printf(“z = %f \n”,z);
}
63
Output:
x = 10.000000
y = 7.000000
z = 4.000000

MANAGING INPUT & OUTUT OPERATORS

MANAGING INPUT & OUTPUT OPERATIONS

  • Reading data from input device, processing it, and displaying the result on the screen are the three task of any program.
  • We have two methods for providing data to the program:
    • Assigning the data to the variable in a program
    • By using the I/O functions
  • Two types of input/output functions:

Download 0,98 Mb.

Do'stlaringiz bilan baham:
1   ...   10   11   12   13   14   15   16   17   ...   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