Computer science 2nd year
1. Which of the given is not a selection statement ? a)While b) if c) if else d) switch
2. In Turbo C, which key used to compile a program a) alt+f9 b) alt+f2 c) ctrl+f9 d) alt+f2
3. If x is an integer variable, x=5%2 return value a) 3 b) 2 c) 1 d) 0
4. First line of a function definition is a)function header b) function body c) argument d) prototype
5. One execution of a loop is known as a) circle b) duration c) iteration d) test
6. If x=10 what will be the value of y? y=(x>5?3:4) a)10 b) 4 c) 3 d) 0
7. The ASCII code for "A" is a) 55 b) 65 c) 97 d) 99
8. Which function is used to write a string to a file a) puts b) printf c) fput() d) getch
9. void Occupy how many bytes in memory a) 4 b) 3 c) 2 d) 0
10. How many types of looping structures are available in C a) 2 b) 3 c) 4 d) 1
Answer the following question
1. What do you know about keywords? 7. Write the use of returns statement.
2. What is the output of the following code 8. Write the syntax of for loop.
x=2;
9. What is the use of go to statement?
y=3;
z=4; 10. What is flowchart?
printf(" answer is %d", x+y*z);
11. What are syntax error?
3. Define getche() function.
12. Find error in the following code
4. Find the error in the following code int x=5:
display("hello") int double=20
input("%d" &x) printf( "result= %d" double)
5. What is the use of if else statement? 13. Determine the output of the following code
int x=7;
6. Convert the following code into while loop
int y=3;
x=10
printf("%d and %d" ,x/y ,x%y);
do {
printf("pakistan ") x=x+1;
} while (x<=15)
Long question
1. Write a program that print the following series using loop 19 16 13 10 7 4 1
2. Explain multiple if else statement with example. Write down it's a sytax. also draw its flowhart.