Input and Output in C 79
EXER CISES
A) A nsw er the following questions.
1) What are the formatted and unformatted functions?
2) What is the difference between charac t e r I/O and s trin g I/0?
3) What are the escape sequences?
4) List any three escape sequences with their uses.
5) What is the difference between puts () andputch ()?
6) What is the difference between getch () and getche ()?
7) H ow iscgets () different from gets ()?
8) How will you execute a dos command through C?
9) What is the use of e x it () function?
B) Select the appropriate options from the choices given below.
1) What will be the output of the following program?
main ()
{
p rin tf ("n %d%d%d%d", ' A ', 'B ' ,'C ’ , 'D ') ;
a) 65666768 b) ABCD
c) 91929394 d) none of the above
2) What will be the values of a and b after execution of the following program?
# include <stdio.h>
# include <conio.h>
mainQ
{
in t a ,b ;
3s65*66i
b='A ' * ' B 'j
c l r s c r ();
printf ("a=%d b=%d",a,b);
a) a=4290 b=4290 b) a=4290b=AB
c) a=4290 b=0 d) none of the above
3) What function is appropriate for accepting a string?
a) getsO b) getchO
c) getcheO d) scanf 0
4) What is the ASCII range for 0 to 9 digits?
a) 48 to 57 b) 65 to 90
c) 97 to 122 d) none of the above
5) What is the ASCII range for A to Z letters?
a) 65 to 90 b) 48 to 57
c) 97 to 122 d) none of the above
6) The escape sequence ' t ' is a
a) tab b) next line
c) backspace d) none of the above
80 Programming and Data Structures
7) What would be the value of x on execution of the program?
# include <stdio.h>
# include <conio.h>
void main ()
{
fl o a t x=2. 3 ;
tSlrscrO ;
x+=.2;
printf C%g",x);
a) 2.5 b) 4.3
c) 4 d) none of the above
8) What will be the output of the following prograih?
main()
{
system ("" );
}
a) control goes to the dos prompt b) syntax error
c) bad command or file name d) none of the above
9) Which is the correct statement for finding the cube of 2 ?
a) pcw (2,3); b) pow (3,2);
c)
pcfw (3); d) none of the above
10) The abs () function displays
a) absolute value b) negative value
c) zero value d) none of th above
C) Attem pt the following program s.
1) Write a program to input the rainfall of three consecutive days in CMS and find its average?
2) Find the simple interest? Inputs are principal amount, period in year and rate of interest.
3) Write a program to find total number of minutes in 12 hours?
4) Find the area and perimeter of a) square b) rectangle? Input the s id e (s ) through the keyboard?
5) Accept any three numbers and find their squares and cubes?
6) The speed of a van is 80 km / hour. Find the number of hours required for covering a distance of
500 km? Write a program in this regard.
7) Write a program to convert Inches to Centimeters.
8) Write a program to enter the name of this book and display it.
9) Write a program to store and interchange two float numbers in variables a & b.
10) Write a program to enter text with g e ts () and display it using p r i n t f () statement also find
the length of the text.
11) Write a program to ensure that the difference between any two-digit number and its reverse
(number interchanged) is always a multiple of nine. For example entered number is 54 and it's
reverse is 45. The difference between them is 9.
12) Write a program to convert kilograms to grams.
13) Write a program to find the total amount when there are 5 notes of Rs.100,3 notes of Rs.50 &
20 notes of Ks.20.
14) Write a program to enter the temperature in Fahrenheit and convert it to Celsius. Formula to be
used is tc= ((tf-32)*5)/9 where tc and tf are temperatures in Celsius and Fahrenheit respectively.
15) Write a program to display list of c program files and directories. Use sy s tem () function to
execute Dos commands.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.133.49