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


MANAGING INPUT & OUTPUT OPERATIONS



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

MANAGING INPUT & OUTPUT OPERATIONS


FORMATTED INPUT FUNCTIONS
(a) scanf( ) function:
  • The scanf( ) function is used to read information the standard input device
    • It is used for runtime assignment of variables.
    • This function is used to enter any combination of input.
  • Syntax: scanf(“format string”, list of addresses of variables);
  • Example: scanf ( "%d %f %c", &c, &a, &ch ) ;

  • Note: & denotes the address of the variable. The values received from keyboard must be dropped into variables corresponding to these addresses.

MANAGING INPUT & OUTPUT OPERATIONS


FORMATTED OUTPUT FUNCTIONS
(a) printf( ) function:
  • The output data or result of an operation can be displayed from the computer to a standard output device ie., Monitor.
  • The function is used to output any combination of data.
  • Syntax: printf(“format string”, list of variables);
  • The format string can contain:
    • Characters that are simply printed as they are.
    • Conversion specifications that begin with a % sign.
    • Escape sequences that begin with a \ sign.
  • Example:

main( )
{
int avg = 346 ; float per = 69.2 ;
printf ( "Average = %d\n Percentage = %f", avg, per ) ;
}

Output:
Average = 346
Percentage = 69.20

MANAGING INPUT & OUTPUT OPERATIONS


UNFORMATTED INPUT FUNCTIONS
  • These statements are used to I/O a single / group of characters from the I/O Device.
  • Here, the user can’t specify the type of data that is going to be Input / Output.

  • (a) getch( ) function:
  • getch( ) accepts only single character from keyboard.
  • The character entered through getch( ) is not displayed in the screen (monitor).
  • Syntax: variable_name = getch( );

  • (b) getchar( ) function:
  • getchar( ) accepts one character type data from the keyboard.
  • It requires Enter key to be typed following the character th6a8t you typed.

Download 0,98 Mb.

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