Decision Control Statement
Decision Control Statement
1. Write a C program to accept a coordinate point in a XY coordinate system and determine in which
quadrant the coordinate point lies.
2. Write a C program to find the eligibility of admission for a professional course based on the
following criteria:
Marks in Maths >=65
Marks in Phy >=55
Marks in Chem>=50
Total in all three subject >=180
3. Write a C program to input electricity unit charges and calculate total electricity bill according to the
given condition:
For first 50 units Rs. 0.50/unit
For next 100 units Rs. 0.75/unit
For next 100 units Rs. 1.20/unit
For unit above 250 Rs. 1.50/unit
An additional surcharge of 20% is added to the bill
4. Write a C program to input the cost price , selling price and maintenance price of the product and
then calculate profit or loss along with profit/loss percentage.
5. Write a C program to input any character and check whether it is alphabet, digit or special character.
6. Suppose you start writing a C program at time T1 (hh:mm:ss). At time T2 (hh:mm:ss) coding is
finished. After compiling code, you get an error, and it took you T3 (hh:mm:ss) time to fix the error.
Write a program to find the total time (hh:mm:ss) that you spent in executing this program.
7. Write a C program to input all sides of a triangle and check whether triangle is valid or not.
8. Write a C program to input grades and credits of five subjects Physics, Chemistry, Biology,
Mathematics and Computer. Find the SPI of student according to the university rule and print the
Grade based on SPI.
9. Write a C Program to find weather an entered year is leap or not.
10. Write a C program to input any character and if its uppercase alphabet then convert it into lowercase
alphabet and vice versa using switch case.
11. Write a C program to find largest of three numbers using nested if-else.
12. Write a C Program to find largest of two numbers using switch case.
13. Write a program to calculate age of a person based on his given date of birth.
14. The output of the code below is (When 1 is entered).
#include <stdio.h>
void main()
{
char ch;
printf("enter a value btw 1 to 3:");
scanf("%c", &ch);
switch ( ch )
{
case "1":
printf("1");
break;
case "2":
printf("2");
break;
}
}
What will be the output of the following programs?
void main()
{
int x = 5;
if (x >1)
printf("hello");
else if (x == 5)
printf("hi");
else
printf("no");
}
void main()
{
int x = 5;
if (x < 1);
printf("Hello");
}
17. #include<stdio.h>
main()
{
int a = 2, b = 4, c = 8, x = 4;
if ( x == b)
x = a;
else
x = b;
if( x != b)
c = c + b;
else
c = c + a;
printf(“c = %d\n”,c);
}
18. #include<stdio.h>
int main()
{
int a = 5;
switch( a )
{
case 1:
printf("First");
case 2:
printf("Second");
case 3 + 2:
printf("Third");
case 5:
printf("Final");
break;
}
return 0;
}
19. #include<stdio.h>
main()
{
unsigned short int x = -10; int y = 10;
if ( y <= x)
printf( “He is good\n”);
if ( y == ( x = -10))
printf( “She is better\n”);
if (( int) x == y)
printf(“it is the best\n”);
}
#include <stdio.h>
int main()
{ int a = 4;
switch (a) {
default:
printf("DEFAULT");
case 1:
printf("ONE");
case 2:
printf("TWO");
case 3:
printf("THREE");
}
}
25. #include<stdio.h>
void main()
{
int w=10, x=5, y=3, z=3;
if( (w<x) && (y=z++) )
printf("%d %d %d %d", w, x, y, z);
else
printf("%d %d %d %d", w, x, y, z);
}
26. #include<stdio.h>
void main()
{
int movie=1;
switch(movie<<2+movie)
{
default:printf("3 Idiots");
case 4: printf(" Ghajini");
case 5: printf(" Krrish");
case 8: printf(" Race");
}
}
27. Write a program to calculate the parking charges of a vehicle. Enter the type of
vehicle as a character(like c for car, b for bus, etc.) and number of hours then
calculate the parking charge given below-
Truck/Bus- Rs. 20 per hour
Car- 10 Rs. per hour
Scooter /Motorcycle- Rs 5 per hour