Sei sulla pagina 1di 2

1. A for statement can be executed within another for statement. This is called ...................

2. The four parts of a for statement are the , the condition, the increment, and the statement(s).
3. The . statement breaks the entire loop, but a .. statement breaks the current iteration.
4. The value of the .. expression is compared with the case constant expression in the order
specified, that is, from the top down.
5. The statement jumps to any point within a function. The destination of the jump is specified
by the name of a label.
6. In the case of a nested switch statement, the statements break the inner switch statement.
7. It is the responsibility of the programmer to make sure the condition is after certain iterations.
8. Group of instructions be executed repeatedly, until some logical condition has been satisfied known as
..
9. The .operator ?: makes use of an expression that is either true or false
10. If the if condition is then the simple or compound statements are executed.

T/f
1. The for loop has four components; three are given in parentheses and one in the loop body.
2. The switch expression should be an integer expression and, when evaluated, it must have an integer
value
3. After a continue statement, the control returns to top of the loop, that is, to the test conditions
4. You can use if-else if when you want to check several conditions but still execute one statement.
5. The case constant expression must represent a particular integer value and no two case expressions
should have the same value
6. The initialization part is executed first and only once.
7. In the absence of a break statement, all statements that are followed by matched cases are executed.
8. In while loop the condition is evaluated before the loop body is executed. If the condition is false
then the loop body is not executed.
9. The execution begins from the case where the switch expression is matched and it flows upward.
10. Switch doesn't have a continue statement

1. What is wrong with the following code fragment/or what will be the output
record = 0; int x=1;
while (record < 100) while(x==1)
{ {
printf( "\nRecord %d ", record ); x=x-1;
printf( "\nGetting next number..." ); printf(%d,x);
}
for (counter = 1; counter < MAXVALUES; counter++); int I=10;
printf("\nCounter = %d", counter while(I=20)
printf(hello);
int I=0 int i;
for(;I;) char ch;
printf(hi); for (i = 0, ch = 'A'; i < 4;i++, ch += 2 * i)
printf("%c", ch);

int I=1,j=1; int I,j,x=0;


for(;;) for(I=0li<5;++i)
{ for(j=0;j<I;++j)
if(I>5) {
break; x+=(I+j-1);
else printf(%d,x);
j+=I; }
printf(%d,j); printf(\nx=%d,x);
I+=j;
}
1. int main(void) 1. int main(void)
2. { 2. {
3. char ch; 3. int age = 20;
4. int lc = 0; /* lowercase char count 4. while (age++ <= 65)
5. int uc = 0; /* uppercase char count 5. {
6. int oc = 0; /* other char count 6. if (( age % 20) == 0) /* is age divisible by 20? */
7. while ((ch = getchar()) != `#') 7. printf("You are %d. Here is a raise.\n", age);
8. { 8. if (age = 65)
9. if (`a' <= ch >= `z') 9. printf("You are %d. Here is your gold
10. lc++; watch.\n", age);
11. else if (!(ch < `A') || !(ch > `Z') 10. }
12. uc++; 11. return 0;
13. oc++; 12. }
14. } 13.
15. printf(%d lowercase, %d uppercase, %d other, lc,
uc, oc);
16. return 0;
17. }
18.

a. #include <stdio.h> 1. #include <stdio.h>


b. int main(void) 2. int main(void)
c. { 3. {
d. int i = 0; 4. int k;
e. while (++i < 4) 5. for(k = 1, printf("%d: Hi!\n", k); printf("k =
f. printf("Hi! "); %d\n",k),
g. do 6. k*k < 26; k+=2, printf("Now k is %d\n", k) )
h. printf("Bye! "); 7. printf("k is %d in the loop\n",k);
i. while (i++ ;lt 8); 8. return 0;
j. return 0; 9. }
k. }
l.

1. Write a program to find the factorial value of any number entered through the
keyboard.
2. Write a loop that will calculate the sum of every third integer beginning with I=2
for all values of I that are less then 100. Write the loop three different ways
Using while, do while, for statement
3. Calculate the sum of the first n odd integer,
4. Write a Program to convert decimal to binary conversion.
Use nested loops to write a program that produces this pattern:
1.
2. $$$$$$$$
3. $$$$$$$$
4. $$$$$$$$
5. $$$$$$$$
5.

Potrebbero piacerti anche