APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY Previous Years Question Paper & Answer

Course : B.Tech

Semester : S1 and S2

Year : 2018

Term : MARCH

Branch : BIOTECHNOLOGY

Scheme : 2015 Full Time

Course Code : CS 100

Page:31





PDF Text (Beta):

Switch case conditions

Switch case 15 clean alternative of ‘if-else-if’ condition. Here, several conditions are given in cases that
facilitates user to select case as per input entered. Basic syntax for using switch case statement is given
below.

switch(expression) { case constant
expression1:

statements1; break; case
constant expression2:

statements1; break;

default : statementsN;
}
#include
int main(int argc,
char *argv[]) { char

ch; int num1, num2;

printf("\nBasic

operation:");

printf("\nAdd [a]"); printf("\nSubtract [५]");
printf("\nMultiply [m]"); printf("\nDivide
[d]");

printf("\nEnter character for operation:"); scanf("%c", &ch);

printf("\nEnter two numbers for operation:");

printf("\nEnter num1="); scanf("%d", &num1);

printf("\nEnter num2="); scanf("%d",

&num2);

switch (ch) { case

a’:
printf("\nAddition of num1 and num2=%d", (num1+num2));

break;

case 's':

Similar Question Papers