CH 3. INPUT/OUTPUT INSTRUCTIONS IN C Flashcards

(53 cards)

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 ___.

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
State the use of foll functions: isdigit()
Checks whether the character is digit
26
State the use of foll functions: Islower()
Checks whether the character is lowercase
27
State the use of foll functions: isprint()
Checks whether the character is printable
28
State the use of foll functions: isspace()
Checks whether the character is whitespace
29
Write the function for foll: 1. to check whether the character is punctuation mark 2. Is a whitespace character 3. Is printable character
``` 1 ispunct() 2 isspace() 3 isprint() ```
30
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
1. %u 2. %ld 3. %x 4. %o 5. %lf 6. %c 7. %s
31
True/false: escape sequence are also included in format specifiers.
True
32
Observe the program: scanf("%3d%2d", &a&b); Input: a=3221,b=20 State/explain the issue in this program.
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
How much one write a program while reading multiple data items in scanf? What can be the error?
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
Explain the foll: use of printf in formatted i/o
Use of field width. If fw>input: leading blanks (right justified) If input>fw: printed in full fw is overwritten (right justified)
35
How does one prints output in c with: Leading 0 Left justification Right justification
O before fw "-" after % Fw>value
36
How can we print/read an float value in exponential form?
Syntax: scanf("%e", &variable name); printf("%w.pe",variable name);
37
State and explain syntax of printf for float
printf("w.pf", variable name); | Explain w.pf
38
%wc is used for ___ in scanf
Characters
39
State the use of foll: %[characters] %[^characters]
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
State the conversion specifier in printf for character.
%wc
41
State the conversion specifier in printf for string | Whats the use of precision?
%w.ps | P specifies first p values would be printed
42
WRITE AND EXPLAIN THE PROGRAM FOR FOLL: | 1. use of scanf for formatted int (with width specifier)
attemt ie write program with accurate output
43
WRITE AND EXPLAIN THE PROGRAM FOR FOLL: | 2. use of printf for printing value with left justification,right justification and leading with 0
attemt ie write program with accurate output
44
WRITE AND EXPLAIN THE PROGRAM FOR FOLL: | 3. scan and print formatted float in exponential form with leading 0, left and right justification.
attemt ie write program with accurate output
45
WRITE AND EXPLAIN THE PROGRAM FOR FOLL: | 4. to take character from user and print it in formats.
attemt ie write program with accurate output
46
WRITE AND EXPLAIN THE PROGRAM FOR FOLL: 5. to take string from user and : a. read only lowercase letters. b. write the input in formats
attemt ie write program with accurate output
47
WRITE AND EXPLAIN THE PROGRAM FOR FOLL: | 6. take mixed values from user and print in formats
attemt ie write program with accurate output
48
WRITE AND EXPLAIN THE PROGRAM FOR FOLL: 7. 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
attemt ie write program with accurate output
49
true/false | scanf returns a int value.
true
50
true/false | mixed datatypes can be input in any order using scanf
false
51
true/false | printf can also print mixed datatypes
true
52
true/false | unformatted i/o is not possible with printf
true
53
true/false | the variable list has to match the format string in type while using printf
true