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

Chapter 10 Half

The document discusses input and output functions in C language. It contains questions and answers related to format specifiers, escape sequences, printf and scanf functions. Programs are given to take user input, perform calculations and display output.

Uploaded by

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

Chapter 10 Half

The document discusses input and output functions in C language. It contains questions and answers related to format specifiers, escape sequences, printf and scanf functions. Programs are given to take user input, perform calculations and display output.

Uploaded by

sirarif113
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Chapter # 10 Input and Output Time: 60 Minutes PART-II

Objective 12 x 1 = 12 Test-15

1. The escape sequence for carriage return is:


a. \a b. \c c. \r d. \f
2. How many variables can be used in one printf function?
a. one b. two c. ten d. many
3. Format specifier starts with symbol:
a. % b. ? c. # d. &
4. Which symbol is used as escape character?
a. \ b. / c. | d. &
5. An ampersand (&) before the name of variable name, denotes:
a. actual value b. variable name c. Address d. Data type
6. All are escape sequences except:
a. \n b. \t c. \del d. \b
7. The escape sequence used to move cursor one character back is:
a. \b b. \t c. \n d. \r
8. Which of the following format specifier is used for integer data type?
a. %d b. %c c. %f d. %s
9. The escape sequence for backslash is:
a. \ b. \b c. \\ d. \t
10. Which escape sequence is used to begin new line in C?
a. \a b. \b c. \m d. \n
11. Which of the following is not a valid escape code?
a. \t b. \v c. \y d. \f
12. Which of the following format specifier is used for float data type?
a. %e b. %d c. %f d. %s

Short Questions 15 x 2 = 30
1. What is the use of printf() function? Write its syntax.
2. Describe clrscr() function.
3. Define format specifiers with example.
4. Discuss the purpose of %C format specifier.
5. Define the format specifier used with printf() and scanf() functions
6. List out four types of format specifier.
7. What is the use of field width specifier?
8. What is an escape sequence? Give examples.
9. Define standard input. List some input functions in c-language.
10. Why the ampersand (&) used in scanf ( ) function?
11. What is the use of scanf function? Also write its syntax.
12. Differentiate between printf and scanf function.
13. Differentiate between getch () and getche ().
14. What is the difference between %e and %g?
15. Describe \n, \v, \t escape sequences with examples.
16. Write a program that inputs distance in kilometers and converts into meters
17. Write a program that inputs temperature in fahrenheit & calculate in Celsius.
18. Write program which takes number from user and display its cube in C.
Long Questions 8 x 3 = 24
1. What is printf() function? Describe with suitable examples.
2. Define the term “escape sequences”. List names and uses with suitable examples.
3. Write a program that accepts two numbers and exchange their values in C language.
4. Write program that inputs three numbers and displays their sums.
5. Write program to subtract two numbers in C language.
Chapter # 10 Input and Output Time: 60 Minutes PART-II
Objective 12 x 1 = 12 Test-16

1. The format specifier %p is used for:


a. Pointer b. unsigned short c. unsigned float d. unsigned long int
2. Which of the following format specifier is used for string?
a. %f b. %d c. %c d. %s
3. The function used for input and output is stored in:
a. stdio.h b. conio.h c. math.h d. tan.h
4. Function which used to get input from the user:
a. printf() b. scanf() c. clrscr() d. puts()
5. The function getch ( ) is defined in:
a. stdio.h b. conio.h c. string.h d. math.h
6. The ASCII code for escape key:
a. 27 b. 28 c. 29 d. 30
7. Which of the following symbol is used with %sign to display output left-justified?
a. - b. / c. \ d. +
8. The format specifier %f is used for:
a. int b. long c. double d. float
9. The format identifier ‘%i’ is also used for _____ data type.
a. char b. int c. float d. double
10. The syntax to print a % using printf statement can be done by ____
a) % b) \% c) ‘%’ d) %%
11. Which of the following format specifier is used for character data type?
a. %d b. %c c. %f d. %s
12. The number of bytes an un-signed integer data type consumes is:
a. 1 b. 2 c. 4 d. 8

Short Questions 15 x 02= 30

1. Find errors: { void main(); printf(“Assembly Lang”); }


2. Trace error: int b=8; int c=0 c=number printf(“%f”,x)
3. Write output: { printf(“Hello World”); }
4. Find errors: main[ ]: float n; printf(“%d”; n); }
5. Show output: int i=515; printf(“i=%5d”, i); printf(“i=%2d”, i);
6. Find output: int x=10, y=20, z=30; x=x+y;y=y+z; z=x-y; printf(“result = %d%d%d”,x,y,z);
7. Find error: int num, num +=5; printf(“\n %d”, num);
8. Trace error: include<STDIO.H> VOID Main(); { printf(“Pakistan”); }
9. Trace output: float f=3.14159; printf(“f=%4.2f”, f);
10. Trace output: char w1,w2,w3; w1=’A’; w2=’B’;w3=’C’; printf(“%c %c w3”, w1,w2);
11. Write output: int x=9; x=x%3; printf(“\n %d result=”, x);
12. Trace output: int x=10; printf(“%d”, x%2);
13. Trace output: int x=1, y=2; x=x+1; y=y+x; printf(“%d \n %d”, x,y);
14. Trace output: int a=10, b=20, temp=b; b=a; a=temp; printf(“%d\n”,a); printf(“%d\n”,b);
15. Trace output: int x=3, y=2, z=4; printf(“%d %d %d”, x+y,y+5,x+z);
16. Write program that inputs length and width of a rectangle and find its area.
17. Write program that inputs radius. Calculate area=πR2 & circumference=2πR using DEFINE Directive.
18. Write program that inputs radius of sphere. Calculate surface area=4πR2 and volume=4/3πR3 using
DEFINE
Long Questions 8 x 3 = 24
1. What is scanf() function? Describe with suitable examples.
2. What is character input? Which functions are used for character input? Explain with examples.
3. Write a program that inputs a string and displays it on the screen.
4. Write a program that displays the sizes of different data types.
5. Write a program that displays the ASCII code of character typed by the user.

You might also like