cp_1_Lect_27 - Program to test a point(x,y lies in I...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
5/10/10 Program to test a point (x,y) lies in I quadrant,II quadrant,III quadrant,IV quadrant,x-axis,y-axis and origin. 11
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
5/10/10 #include<stdio.h> main() { float x,y; printf(“enter x and y values \n”); scanf(“%f%f”,&x,&y); printf(“point lies in 1st quad.\n”); else printf(“point lies in 2nd quad.\”); else printf(“point lies in 3rd quad.\n”); else printf(“point lies in 4th quad.\n”); 22
Background image of page 2
5/10/10 Multi-way selection val2 act val1 act val3 act Multi way exp val1 val2 val3 val4 val4 act switch (expression) { case const1 : statement statement case const2 : statement statement default : statement statement (Decision logic) (Switch syntax) Points to note: ANSI C: 257 case labels No two case labels can have the same constant value Two case labels can be associated
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
5/10/10 The switch statement is a multi-way decision that tests whether an expression matches one of a number of constant integer values, and branches accordingly. switch ( expression ) { case value-1 : block1 break; case value2 : block2 break; …… default: default-block 44 The expression is an integer expression or characters. Value-1 value-2…are integer-valued constants or constant expressions.
Background image of page 4
The switch statement Cases and the default clause can occur in any order. The break statement at the end of each block signals the end of a particular case and causes an exit from the switch statement, transferring the control to the statement-x following the switch. 55
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 23

cp_1_Lect_27 - Program to test a point(x,y lies in I...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online