0% found this document useful (0 votes)
44 views2 pages

Computer 12 CH10 SQs

This document discusses input and output statements in C programming. It defines output statements as functions used to display data from a program, with printf being commonly used. Input statements provide data to a program, with scanf used to get user input at runtime. Format specifiers like %d are used with input and output statements to represent the data type and format of variable values. Escape sequences starting with \ are used to control output.

Uploaded by

9t6vx7psm5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views2 pages

Computer 12 CH10 SQs

This document discusses input and output statements in C programming. It defines output statements as functions used to display data from a program, with printf being commonly used. Input statements provide data to a program, with scanf used to get user input at runtime. Format specifiers like %d are used with input and output statements to represent the data type and format of variable values. Escape sequences starting with \ are used to control output.

Uploaded by

9t6vx7psm5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

[Ch#10] Input/Output 280 Computer Science Part-II

Q.1 What is an output Statement?


Ans. Output statements (functions) are used to get data from the program. Output
produced by monitor is called standard output e.g. printf( )
Q.2 What is an printf( )?
Ans. It is used to display messages. It can be accessed by including standard input /
output header file stdio.h in the program. It takes formatted string and list of
variables as an argument. The values of variables are displayed according the
specified format in the string.
printf(“Format specifiers Control string” , var-1, var-2,……..);
Q.3 What are Format Specifiers?
Ans. A format specifier represents data type field width and format of a value of a
variable displayed on the screen. A format specifier always begins with the
symbol %. Format specifiers are used for both input and output statements. For
different types different format specifiers are used e.g. %d, %s , %c, etc.
Q.4 What is Field Width Specifier?
Ans. It is defined as the number of columns used to display a value on the screen. Its
use is optional. If the value requires more columns, then the field is expanded. If
the value is smaller than the specified number of columns then the extra spaces
are padded before or after the value.
Q.5 What is an Escape Sequence?
Ans. These characters are used to control output on the output devices. These
characters are not printed on the output devices. An escape sequence is a
combination of a backslash and a single character. Backslash \ is called control
character. And next single character after backslash is called code character.
These are used in control string. These characters cause a different meaning from
the normal interpretation e.g. \n represents new line, \t shows tabs etc.
Q.6 What is an input Statement?
Ans. Input statements (functions) are used to provide data to the program. The input
given o the computer through keyboard is called standard input. There are two
types of input
Design time input
[Ch#10] Input/Output 281 Computer Science Part-II
Run time input
Q.7 What is Design Time Input?
Ans. It is also called programmer’s input or simple input. It is given by the programmer
at the time of writing programs (coding). It remains constant during the execution
of the program. Example: int x=5,y=9;
Q.8 What is Run Time Input?
Ans. It is given at the time of execution of the program (after compilation). It is called
user input. scanf( ), getch( ), getche( ) are the functions to get run time input.
Q.9 What is scanf() Function?
Ans. It is used to get values of the variables (numeric and string) from user. It can be
accessed by including standard input / output header file stdio.h in the program
(means stdio.h is a prototype for scanf( ) function). It takes formatted control
string and list of variables as an argument to hold the value of variables. scanf()
requires the address of the variable to store the value into it. Ampersand sign (&)
is used before the variable name as an address of operator. If & sign is omitted the
scanf function will not locate the variable in memory.
Syntax: scanf(“List of Format specifiers”, &var-1, &var-2, &var-3, ……..);
Q.10 What is a getch( ) Function?
Ans. It is used to get a single character as input from the keyboard during the execution
of the program. The prototype of getch( ) function is conio.h (console
input/output) header file. It does not accept any argument. There is no
requirement of pressing enter key after typing the character.
Syntax: getch( ); or variable_name = getch( ); variable name is optional.
Q.11 What is getche( ) Function?
Ans. It is used to get a single character as input from the keyboard during the execution
of the program. The prototype of getch( ) function is conio.h (console
input/output) header file. It does not accept any argument. There is no
requirement of pressing enter key after typing the character.
Syntax: getche( ); or variable_name = getche( ); variable name is optional.
Q.12 What is the difference between getch( ) and getche( ) functions
Ans. getch( ) does not display the entered character on the screen while getche( )
displays the entered character on the screen.

You might also like