CH 3. INPUT/OUTPUT INSTRUCTIONS IN C Flashcards

1
Q

c language uses __ in place of i/o instructions

A

functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

there are some functions which have became standard for i/o these functions are stored in ___

A

standard i/o library ie header file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

before writing input output instructions every program must include ___

A

include

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

state the use of #include in program

A

the statement will tell the compiler to search for the file, place its contents at the program. the contents of header will now be a part of program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

state the types of i/o in c

A

console i/o
disk i/o
port i/o

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is console i/o

A

the input is supplied from keyboard and output is printed on terminal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is disk i/o

A

i/o on floppy disks or hard disks ie secondary storage devices

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is port i/o

A

i/o operations on ports

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

the function used to input data is ___.

A

printf

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

the function used to output data is __

A

scanf

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

most of the standard i/o operations are included in ___ file.

A

stdio.h

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

console i/o can be ___ and ___

A

formatted and unformatted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

___ i/o allows us to input/display output as per our requirements

A

formatted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what is formatted i/o?

A

,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Getch() are used to read characters in ____ input/output

A

Unformatted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

State the use of foll functions:

Getch()

A

Used in unformatted i/o. Used to read input from terminal without displaying it on screen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

State the use of following functions:

Getche

A

Will read the character typed with echoing(displaying) the enterer character on screen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

State the use of foll: getchar()

A

Used to read unformatted input and the entered characters will rchoe on screen when enter key is typed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

State the use of foll: putch()

A

Outputs unformatted character on screen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

State the use of foll: putchar()

A

Used to print unformatted output when the variable is hardcored. The syntax is putchar(variable name)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

State syntax of foll:
Getchar
Putchar

A
  1. Getchar: variable name=getchar();

Putchar: putchar=(variable name);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Character functions are stored in headerfile ___.

A
23
Q

State the use of following functions in c:

Isalnum()

A

Checks whether the character is alphanumeric

24
Q

State the use of foll functions: isalpha()

A

To check whether the character is alphabet

25
Q

State the use of foll functions: isdigit()

A

Checks whether the character is digit

26
Q

State the use of foll functions: Islower()

A

Checks whether the character is lowercase

27
Q

State the use of foll functions: isprint()

A

Checks whether the character is printable

28
Q

State the use of foll functions: isspace()

A

Checks whether the character is whitespace

29
Q

Write the function for foll:

  1. to check whether the character is punctuation mark
  2. Is a whitespace character
  3. Is printable character
A
1 ispunct()
2 isspace()
3 isprint()
30
Q

Write conversion specifier for the foll datatype:

  1. Short unsigned int
  2. Long signed int
  3. Unsigned hexadecimal
  4. Unsigned octal
  5. Double real
  6. Character unsigned
  7. String
A
  1. %u
  2. %ld
  3. %x
  4. %o
  5. %lf
  6. %c
  7. %s
31
Q

True/false: escape sequence are also included in format specifiers.

A

True

32
Q

Observe the program:
scanf(“%3d%2d”, &a&b);
Input: a=3221,b=20

State/explain the issue in this program.

A

Here, the width specified is less than the actual input. So, scanf will assign a=322,b=21 and will automatically stop post 1 and will not read b value. In order to avoid such situations one must either mention the accurate field width or just skip the field width.

33
Q

How much one write a program while reading multiple data items in scanf? What can be the error?

A

If the datatyoe doesnt match the dataitem scanf will skip reading further input. In order to avoid that…One must seperate the dataitems by spaces, newlines, tabs.

34
Q

Explain the foll: use of printf in formatted i/o

A

Use of field width.
If fw>input: leading blanks (right justified)
If input>fw: printed in full fw is overwritten (right justified)

35
Q

How does one prints output in c with:
Leading 0
Left justification
Right justification

A

O before fw
“-“ after %
Fw>value

36
Q

How can we print/read an float value in exponential form?

A

Syntax:
scanf(“%e”, &variable name);
printf(“%w.pe”,variable name);

37
Q

State and explain syntax of printf for float

A

printf(“w.pf”, variable name);

Explain w.pf

38
Q

%wc is used for ___ in scanf

A

Characters

39
Q

State the use of foll:
%[characters]
%[^characters]

A
  1. Used by scanf for string.The characters entered in the [ ] are allowed in string. Used to read strings which have blank spaces
  2. The characters inside the [ ] is not allowed in input string. Scanf will take values except them.
40
Q

State the conversion specifier in printf for character.

A

%wc

41
Q

State the conversion specifier in printf for string

Whats the use of precision?

A

%w.ps

P specifies first p values would be printed

42
Q

WRITE AND EXPLAIN THE PROGRAM FOR FOLL:

1. use of scanf for formatted int (with width specifier)

A

attemt ie write program with accurate output

43
Q

WRITE AND EXPLAIN THE PROGRAM FOR FOLL:

2. use of printf for printing value with left justification,right justification and leading with 0

A

attemt ie write program with accurate output

44
Q

WRITE AND EXPLAIN THE PROGRAM FOR FOLL:

3. scan and print formatted float in exponential form with leading 0, left and right justification.

A

attemt ie write program with accurate output

45
Q

WRITE AND EXPLAIN THE PROGRAM FOR FOLL:

4. to take character from user and print it in formats.

A

attemt ie write program with accurate output

46
Q

WRITE AND EXPLAIN THE PROGRAM FOR FOLL:

  1. to take string from user and :
    a. read only lowercase letters.
    b. write the input in formats
A

attemt ie write program with accurate output

47
Q

WRITE AND EXPLAIN THE PROGRAM FOR FOLL:

6. take mixed values from user and print in formats

A

attemt ie write program with accurate output

48
Q

WRITE AND EXPLAIN THE PROGRAM FOR FOLL:

  1. value of a=600, b=65.783, ch=’a’
    a. print a in jsutified form
    b. leading 0 with precision 4/exponent form
    c. with formats
A

attemt ie write program with accurate output

49
Q

true/false

scanf returns a int value.

A

true

50
Q

true/false

mixed datatypes can be input in any order using scanf

A

false

51
Q

true/false

printf can also print mixed datatypes

A

true

52
Q

true/false

unformatted i/o is not possible with printf

A

true

53
Q

true/false

the variable list has to match the format string in type while using printf

A

true