APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY Previous Years Question Paper & Answer

Course : B.Tech

Semester : S1 and S2

Year : 2018

Term : MARCH

Scheme : 2015 Full Time

Course Code : CS 100

Page:3





PDF Text (Beta):

Answer Key

PART A

1.

Break Continue

۸ break can appear in both switch and A continue ೦೩/೧ appear only in loop (for, loop (for, while, do)
statements. while, do) statements.

۸ break causes the switch or loop A continue doesn't terminate the loop, it statements to terminate the
moment it causes the loop to go to the next is executed. Loop or switch ends iteration. All iterations of
he loop are abruptly when break is encountered. executed even if continue is encountered. The
‘ontinue statement is used to skip statements in the loop that appear after the continue

he break statement can be used in both The continue statement can appear only switch and loop
statements. in loops. You will get an error if this appears in switch statement.

hen a break statement is encountered, When a continue statement is it terminates the block and gets
he encountered, it gets the control to the control out of the switch or loop. next iteration of the loop.

A break causes the innermost enclosing A continue inside a loop nested within a loop or switch to be
exited immediately. switch causes the next loop iteration.

Eg,Pgm for Continue
#include

int main()
{
int a[10] = {-1, 2, -3, 4, -5, 6, -7, 8, -9, 10];
int i, sum 50; for (i = 0; i < 10; i++)
{
if )3][ < 0) /* skip negative elements */
continue;
sum += a[i]; /* sum positive elements */

}

printf("Sum of positive elements: %d\n", sum);

}

OUTPUT

Sum of positive elements: 30

Eg.pgm for break
int main()

{

int i;

Similar Question Papers