Assignment Itc 2
Assignment Itc 2
To be filled by students
Student name: MAAZ NASIR
Registration No: LIF22BSCS1051
#include<iostream>
int main ()
int service,salary,bonus;
cin>>salary;
cin>>service;
if(service>5){
salary=bonus+salary;
else{
return 0;
}
Q.2(a)
2. a) A student will not be allowed to sit in exam if his/her attendence is less than 75%. Take following
input from user Number of classes held Number of classes attended. And print percentage of class
attended Is student is allowed to sit in exam or not.
#include<iostream>
int main ()
cin>>totalclasses;
cin>>classesattended;
if(classesattended<=totalclasses){
percentage=(classesattended/totalclasses)*100;//formula for percentage.
cout << "Student is not allowed to sit in exam because his/her percentage is
below 75";
else
else{
return 0;
}
Q.2(b)
Modify the above question to allow student to sit if he/she has medical cause.
Ask user if he/she has medical cause or not ( 'Y' or 'N' ) and print accordingly.
#include<iostream>
int main() {
float c , e;
cin>>c;
cin>>e;
char f;
cout<<"Do you have a medical cause? 'Y' for yes and 'N' for no.\n";
cin>>f;
switch(f) {
case 'y':
break;
case 'n':
break;
default:
cout<<"Invalid input.";
} else {
return 0;
#include<iostream>
int main() {
int x=2;
int y=5;
int z=0;
}
Q5. Write a program to check whether a entered character is lowercase ( a to z )
or uppercase ( A to Z ).
#include<iostream>
int main() {
char ch;
cin>>ch;
if(ch>='A'&& ch<='Z'){
cout<<"character is uppercase""\n"<<ch<<endl;
else{
cout<<"incorrect data";
return 0;
}
Q.6
Write a program to check if a year is leap year or not. If a year is divisible by 4
then it is leap year but if the year is century year like 2000, 1900, 2100 then it
must be divisible by 400
#include<iostream>
int main()
cin>>a;
return 0;
}
Q.7
Ask user to enter age, sex ( M or F ), marital status ( Y or N ) and then using
following rules print their place of service. if employee is female, then she will
work only in urban areas. if employee is a male and age is in between 20 to 40
then he may work in anywhere if employee is male and age is in between 40 t0
60 then he will work in urban areas only. And any other input of age should
print "ERROR".
#include<iostream>
int main()
int age;
char gender,mstatus;
cin>>age;
cout<<"enter the gender if male type ='M ' ,if female type='F':" <<gender
<<endl;
cin>>gender;
cin>>mstatus;
if(gender=='f'|| gender=='F'){
cout<<"she will work only in urban areas."<<endl;
if(gender=='m'|| gender=='M'){
if((age>=20)&&(age<=40)){
else if((age>=40)&&(age<=60)){
else{
return 0;
}
Q8. A 4 digit number is entered through keyboard. Write a program to print a
new number with digits reversed as of original one. E.g.- INPUT : 1234 OUTPUT :
4321 INPUT : 5982 OUTPUT : 289
#include<iostream>
int main()
int Num,reverse;
cin>>Num;
while(Num>0){
reverse=Num%10;
cout<<reverse;
Num=Num/10;
return 0 ;