Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

1. What are Control structures?

Ans: These are the programming statements, which controls the sequence of
program execution.Some statements are executed based on conditions.Some
statements gets executed repeated number of times.
2. If a semicolon is put at the end of [for, if, else, while etc]. Explain the results?
Ans:
Semicolon at the end of for loop
for(I=1;I<=10;I++);
printf(%d\n, I);
output : 11
Semicolon at the end of while loop
I = 1;
while( I <= 10 );
{
printf(%d, I);
}
output : Program runs for infinite times without printing anything
Semicolon at the end of if condition
Case I:
if (n > 10);
printf(Hai\n);
else
printf(Bye);
Error : hanging else

Case II:
if( n > 10 );
printf(Hai\n);
printf(Bye);
Output:
If n is > 10 then
Hai
If n <= 10 then output would be:
Hai
Bye
Semicolon at the end of else
if(n > 10 )
printf(Hai);
else;
printf(Bye);
Output: Bye would be printed always, The printed of Hai depends on the condition
4. When to use what loop?
Ans:
For loop:
If we have all the three sections directly (initialization; testing; modification)
Ex1 : for( I = 1; I<=n;I++)
Also these sections should be small statements

If modification should take place at the end


If we know in advance the number of times the loop should run.
While loop:
If we dont have all the three sections directly
ex1: reverse a number while( n )
Ex: n = n/10;
Also if modification is in the middle of the loop block.
Ex: raindrops program
If we dont know in advance, the number of times a loop should run.
Do- while loop
Same as that of while loop, except that it runs at least once.
6. Is it necessary to define a label with every goto statement? Justify your
statement?
Ans: Yes. Otherwise how can it know where to transfer the control.

TWO MARKS:
UNIT 1
1. What is a computer?
2. What are programming developing steps?
3. Define an algorithm?
4. Define flow chart?
5. What are the advantages and disadvantages of an algorithm?
6. What are the advantages and disadvantages of a flowchart?
7. What are the operators used in c language?
8. What are C tokens?
9. Write down the rules for variables?
10. What is type casting and type conversion?
11. What are keywords?
12. Define identifiers?
13. What is a constant?
14. What is a compiler?
15. What is a linker?
16. Draw the different symbols used in flow chart?
17. What are the characteristics of algorithm?
18. Write the features of C?
19. Write the character set in C language?

20. Write the classification of constants in c language?


21. Define data type? Write the ranges of different data type?
22. Define expression and differentiate C expression with algebraic expression?
23. Write the rules for expression evaluation?
24.

You might also like