Professional Documents
Culture Documents
MATRIC ID : C-201234
Solution :
#include<stdio.h>
int main()
int unit;
float amount,net_bill,minimum_charge;
minimum_charge=90;
scanf("%d",&unit);
amount=unit*4.5;
else if(unit>=250)
amount=250*4.5+((unit-250)*72);
}
else
net_bill=amount+minimum_charge;
return 0;
}
Problem no. 02 : Write a C program to input basic salary of an employee and
calculate the gross salary .
Solution :
#include<stdio.h>
int main()
float basic_salary,gross_salary,da,hra;
scanf("%f",&basic_salary);
if(basic_salary<=10000)
da=basic_salary*0.8;
hra=basic_salary*0.2;
else if(basic_salary<=20000)
da=basic_salary*0.9;
hra=basic_salary*0.25;
else
{
da=basic_salary*0.95;
hra=basic_salary*0.3;
gross_salary=basic_salary+da+hra;
return 0;
}
Problem no. 03 : Write a C program to check whether the number is odd or
even using switch .
Solution :
#include<stdio.h>
int main(){
int integer;
int remainder;
scanf("%d",&integer);
remainder=integer%2;
switch(remainder)
case 0:
break;
default:
return 0;
}
Problem no. 04 : Write a C program to design basic operations of a calculator
using switch .
Solution :
#include <stdio.h>
int main() {
char operator;
scanf("%c", &operator);
switch(operator)
case '+':
break
case '-':
break;
case '*':
printf("%.1f * %.1f = %.1f",n1, n2, n1*n2);
break;
case '/':
break;
default:
return 0;
}
Problem no. 05 : Write a C program to print gender (male/female) according
to the given input m/f using switch .
Solution :
#include<stdio.h>
int main()
char gender;
scanf("%c",&gender);
switch(gender)
case'm':
case'M':
printf("\nThis is male");
break;
case'f':
case'F':
printf("\nThis is female");
break;
default:
return 0;
Problem no. 06 : Write a switch statement that will examine the value of an
integer variable called department and print messages depending on the value
assigned to department .
Solution :
#include<stdio.h>
int main()
int department;
scanf("%d",&department);
switch(department)
case 1:
printf("\nThis is CSE department.");
break;
case 2:
break;
case 3:
break;
default:
return 0;