Professional Documents
Culture Documents
Lab Sessional - SP2021
Lab Sessional - SP2021
Lab Sessional - SP2021
Attock Campus
Department of Electrical and Computer Engineering
Question 1: [CLO-1,4]
A company gives a certain amount of allowance to its employee in the following cases:
− 30% of basic salary if the employee is married and has children.
− 20% of basic salary if the employee is unmarried, male & has experience of 5 years.
− 20% of basic salary if the employee is unmarried, female & has experience of 4 years.
In all other cases the employee is not given an allowance. If the basic salary, marital status, gender
and experience of the employee are the inputs, write a program to determine whether the employee
will get an allowance or not and compute his total salary.
Question 2: [CLO-2,4]
A 5-digit positive integer is entered through the keyboard, write a function to check how much
number of its digits is even and odd and then display those digits respectively. Some sample
interaction with the program might look like this:
Enter a five digit number: 92347
The number of even digits in 92347 is 2 and even digits are 2& 4.
The number of odd digits in 92347 is 3 and odd digits are 9,3& 7.
Answer:
Coding:
#include <stdio.h>
int main()
{
Answer:
Coding:
int main ()
{
int num,num1,num2,num3,num4,num5,numm;
printf("enter the five digit number");
scanf("%d",&num);
numm=num;
num5=num%10;
num=num/10;
num4=num%10;
num=num/10;
num3=num%10;
num=num/10;
num2=num%10;
num=num/10;
num1=num%10;
if (num1%2)
{
printf("Enter numbers are even:")
}
else
{
printf("Enter numbers are odd:")
}}
Output: