Introduction to Computer Programming


Variables and Identifiers



Download 0,68 Mb.
bet3/4
Sana27.06.2022
Hajmi0,68 Mb.
#709414
1   2   3   4
Bog'liq
270 1 CIntro Up To Functions

Variables and Identifiers

  • Variables have names – we call these names identifiers.
  • An identifier must begin with a letter or an underscore _
  • C is case sensitive upper case (capital) or lower case letters are considered different characters. Average, average and AVERAGE are three different identifiers.
  • Numbers can also appear after the first character.
  • However, C only considers the first 31 (external identifiers) or first 63 (internal identifiers) significant.
  • Identifiers cannot be reserved words (special words like int, main, etc.)

User Input

  • Let’s rewrite the average program so it can find the average any 3 numbers we try:
  • We now need to:

Average3.c

  • #include
  • int main(void)
  • {
  • int value1, value2, value3;
  • float sum, average;
  • printf("What is the first value? ");
  • scanf("%d", &value1);
  • printf("What is the second value? ");
  • scanf("%d", &value2);
  • Read
  • The address of variable value1

  • printf("What is the third value? ");
  • scanf("%d", &value3);
  • sum = value1 + value2 + value3;
  • average = sum / 3;
  • printf("The average of %d , %d, %d is %f\n", value1, value2, value3, average); return(0);
  • }

Scanf Conversion Characters

  • https://wpollock.com/CPlus/PrintfRef.htm#scanfConv Doubles on our machine are read with a lf. (A double is a long float.)

Download 0,68 Mb.

Do'stlaringiz bilan baham:
1   2   3   4




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