Вы находитесь на странице: 1из 2

School of Computer Engineering, PROGRAMMING IN C

KIIT University, Bhubaneswar (Branching: if…else, else-if ladder, switch case)

Branching (SHORT TYPE) return 0;


}
2.1 Write the syntax of ternary operator in C.
Give a suitable example. 2.10 What will be output of the following c
2.2 Write a single statement in C to find the program?
smallest one among three integer a, b and c. int main()
2.3 Write the syntax of else- if ladder and explain {
it's working. int x=1,y=2,z=3;
2.4 Write short note on Unconditional branch. if(x=y%2)
2.5 Is it necessary to use default case in switch- y=x;
case structure? z=x;
2.6 What is the difference between else-if ladder printf("%d, %d, %d ",x, y, z);
and switch case? return 0;
2.7 What would be the output ? }
void main()
{ 2.11 What will be output of the following c
int x=10, y=17; program?
if(x>y) void main( )
printf(“KIIT”); {
else if (x-y) int x=5;
printf(“KISS”); if (1>x<8)
else printf ("WORLD');
printf(“KIMS”); else
} printf ("UNIVERSE')
return 0;
2.8 What will be output of the following c }
program?
#include<stdio.h> 2.12 What will be output of the following c
int main() program?
{ int main()
int x=1,y= -2; {
if(x=y); int x=0,y= 1, z=-2;
{ if(x>y || y<z && z>x)
x=x+y; printf(“CSIT”);
} else
printf(“%d”,x+y); printf(“OTHERS”);
return 0; return 0;
} }

2.9 What will be output of the following c 2.13 Write the output of the following code
program? void main( )
int main() {
{ int x=-2,y;
int a= 0;int b = 1;char c=2;char d = -3; y=!x;
if(a,b,c,d) switch(y)
printf("SUN"); {
else default: printf("\nStudent”);
printf("MOON"); case 0: printf("\nKIIT”);break;

KIIT/CS 1001: Programming in C (PC) Home Assignments Page 1


School of Computer Engineering, PROGRAMMING IN C
KIIT University, Bhubaneswar (Branching: if…else, else-if ladder, switch case)

case 1: printf("\nKISS”'); 2.19 WAP to find the roots of a quadratic equation


case 2: printf("\nKIMS");break; ax2+bx+c=0 using if-else statement.
} 2.20 WAP to read an alphabet from from the user
} and convert it into lowercase if the entered
alphabet is in uppercase, otherwise display an
2.14 Write the output of the following code appropriate message.
void main( ) 2.21 WAP to check whether a character entered
{ through keyboard is a digit, letter, special
int x=-2,y; character etc or not.
y=!(x+2); 2.22 WAP to input any two integers, and provide a
switch(y) menu to the user to select any of the options
{ as add, subtract, multiply, divide and display
default: printf("\nStudent”); the result accordingly.
case 0: printf("\nKIIT”);break; 2.23 WAP to display the grade system of KIIT
case 1: printf("\nKISS”'); University based on total marks secured by a
case 2: printf("\nKIMS");break; student in a semester. Use else..if ladder
} statement.
} The grade is calculated is as follows:
Marks Grade
2.15 Assuming that x=2,y=1 and z=0 intially ,what 90 to 100 O
will be their values after executing the 80 to 89 E
following code segments? 70 to 79 A
switch(x) 60 to 69 B
{ 50 to 59 C
case 2 : 40 to 49 D
x=1; < 40 F
y=x+1; 2.24 WAP to display the grade system of KIIT
case 1 : University based on total marks secured by a
x=0; student in a semester. Use switch-case
break; statement.
default : 2.25 WAP to calculate tax, given the following
x=1; conditions.
y=0; (a) If income is less than 1,50,000 then no tax
} (b) If income is in the range 1,50,001-
3,00,000 then charge 10% tax
Branching (LONG TYPE) (c) If income is in the range 3,00,001-
5,00,000 then charge 20% tax
WAP stands for Write a program

2.16 WAP to read a character from the user and


test it whether it a vowel or consonant or not
an alphabet.
2.17 WAP to determine whether a year entered
through the keyboard is a leap year or not.
2.18 WAP enter data in rnm/dd/yy format from the
keyboard and print next day date and also
check whether the next day is in a leap year or
not.

KIIT/CS 1001: Programming in C (PC) Home Assignments Page 2

Вам также может понравиться