0% found this document useful (0 votes)
42 views3 pages

Lab Sessional - SP2021

The document provides instructions for a programming lab sessional assignment with two questions - the first asks students to write a program to calculate an employee's total salary based on their basic salary, marital status, gender, experience and whether they have children. The second question asks students to write a function to determine the number of even and odd digits in a 5-digit positive integer and display those digits. The document provides example inputs and outputs for the programs and reminds students to submit their code and answer documents by the deadline.

Uploaded by

Talha Tufail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views3 pages

Lab Sessional - SP2021

The document provides instructions for a programming lab sessional assignment with two questions - the first asks students to write a program to calculate an employee's total salary based on their basic salary, marital status, gender, experience and whether they have children. The second question asks students to write a function to determine the number of even and odd digits in a 5-digit positive integer and display those digits. The document provides example inputs and outputs for the programs and reminds students to submit their code and answer documents by the deadline.

Uploaded by

Talha Tufail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

COMSATS University Islamabad

Attock Campus
Department of Electrical and Computer Engineering

Program: BCE-2Spring 2021


LabSessional I
Course: Programming Fundamentals
Time Allowed: 1h 10mins Marks: 30
Name: ______________________________________ Reg. No: _______________________________
Note: Each question carries 15 marks
Instructor’s E-mail id: [email protected]
Instructions:
1. You have to submit your answer document & code file via both MS Teams & email.
2. Save document file with your Name and Registration number.
3. No late answers would be accepted.

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()
{

char marital, gender, child,basic_s,total_s;


int exper;
printf("Enter the Basic Salary: ");
scanf("%d", &basic_s);
printf("Enter the experience: ");
scanf("\n%d", &exper);
printf("Enter the Marital Status, 'm' for Married & 'u' for Unmarried: ");
scanf("\n%c", &marital);
printf("Enter the Gender, 'm' for Male & 'f' for Female: ");
scanf("\n%c", &gender);
printf("Do you have children?, 'y' for Yes & 'n' for No: ");
scanf("\n%c", &child);
if (marital=='m' && child=='y')
{
total_s = basic_s*0.3;
printf("Allowance of 30 percent of basic salary will be given.");
printf("Total salary is %d", total_s);
}
else if (marital =='u' && gender =='m' && exper =='5')
{ }
else if (marital =='u' && gender =='m' && exper =='5')
{
total_s = basic_s*0.2;
printf("Allowance of 20 percent of basic salary will be given.");
printf("Total salary is %d", total_s);
}
else if (marital =='u' && gender =='f' && exper =='4')
{
total_s = basic_s*0.2;
printf("Allowance of 20 percent of basic salary will be given.");
printf("Total salary is %d", total_s);
}
else
printf("The employee will not get allowance.");
}
Output:

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:

You might also like