Professional Documents
Culture Documents
Programming Lab Assignment01
Programming Lab Assignment01
qPP u,ayantenquepp
Create an Employee class to enter and display informat ion of employee such as Emp1D, Name, Address, Designation
01. Salary
Aand of Last five years and calculate average saiary (create five objects to enter and display dato).
includeciostrea
using namespace stdj
7 class Employeel
9 tring name, id, address, designation;
e float salary[5]i
11
13 float average()
float s
6
for (int i-8; ic5;i-))
sum Sumsalary[i]i
19 return Sun
lab_assgnmentogJ5.cpP ao8539
lab assignment01 q01.cpp lab assignment01 qd2.cpp
22
23 int main()
24
25 cless Eployee e[S]
for (int i-e,ie5;i*)
27
28 cin.clear)
fflush(stdin);
coute"Enter Data 0f Employee no. "eci+1«cendl
cout"Employee's Name: "
getline(cin, e[i].name)
33 cin.clear ()
fflush(stdin) ;
coute«"Employee's ID:"
getline(cin, e[i].id) ;
cin.clear()
fflush(stdin);
coute"Employee's Address: "
getline(cin, e[£].address)
cin.clear()s
42 fflush(stdin)
43 coute"Employee's Designation "
44 getline (cin, e[4].designation )
45 cin.clear ()
46 fflush(stdin);
47 coutce Employee's Salary 0f Last 5 years : "cendl;
for(int j-0,je5ij**)
5 coute«j-1c« Year(s) Back: "
51 cine[i].salary[jls
52
coutecendl«cendl;
couteend1
56
57 for(int i-ejic5j i*)
58
59 cout« "Data Of Employee no. "cci+1c<endl
60 coute"Employee's Name: "<ce[i].nameccendl;
6 coute"Employee"s ID: "ece[i].idecendl
62 cout«e"Employee's Address: "e[i].addressecendl;
coutee"Enployee's Designation : ce[i].designat ione cendl;
64 cout«"Employee's Salary 0f Last 5 years: "<cendl;
65 for (int j-0sje5ij*)
66
67
68
cout«j 1«e" Year(s) Back : "cce[i].salary[j]<cendl;
69 coutee"Average Salary: "c«e[i].average () <cendlecendl;
71
return
73
BFlc PROGRAMlab assignment01 q01.exe
Enter Data Of Employee no.
5
Employee 's Salary 0f Last years
1 Year(s) Back:5eeee
2 Year(s) Back : 40000e
3008
3 Year(s) Back:
Year(s) Back 20000
:10e00
5 Year(s) Back
Emp loyee's ID : 2
Employee's Address sangli
Designation cleark
Emp loyee 's 5
Employee's Salary Of Last years:
1 Year(s) Back : 20000
Employee's Address:sangli
cleark
Employee's Designation :
1 2.irite a
program using
class
to accept 5
numbers from user and
dtsplay Larges t,
number omong ffve.
2 econd largest and smallest, second smallest and middle
includecbits/stdc++.h>
uSing namespace stdj
ain()
T
coutee"Enter 5 Numbers: "<<endlj
int arrl5]
tor (int 1-djic5ji)
cin>>arr[1]
1
sort(arr, lest
routse"2nd Smallesst
Nunber :
"e<arr[e]<<endl
Nunber: "<<arr[1]<<endl
coute"Middle Number: "<carr[2]<«endl;
:
cout2nd Largest Number <carr[3]<endlj
coutee"Largest Number: "<carr[4]<«endlj
return
FlcPROGRAMMJab_assignment01.q02.exe
Enter 5 Numbers :
Smallest Number : 1
2nd Smallest Number : 2
iddle Number 3
2nd Largest Number: 4
Largest Number: 5
includeciostream>
Using namespace std;
int main()
the value of
cout<Enter a,b &c: "ccendl;
ana>0>>ci
float
14
(a"b) xce
coutee"x ((float)ci )
return e
17
18
FAcPROGRAMIab_assignment01.q03.ee
Enter the value of a,b & c :
2 Super prime number is one whose all digits are prime and number is also prime)
3
5
ncudecl0strea
#include ccmath>
using nanespace std;
int count-e
11
it(n=*1)
return
if(n2
return1 n-3)
for(int i-2jic-sqrt (n) si**)
if(ni-0)
countj
break;
6(coun
return 1
27
28 int issuperPrime (int n)
29
int r
uhile (n>e)
32
35 ren10
4 if(isPrime(r))
35 return e;
36 n-n/1e
37
38 return 1;
39
40
41 int ain)
42 int n
44 cin>n
45 if(isPrime (n) )
46
47 coutee"Not A Super Prime Nunber"ccendl1
48 return e
49
59 if(isSuperPrime(n) )
S1
4#includeciostream>
5 #include <string
6
using nemespace std
ain()
T
string s "CPP is
easy and great and Python is also great"
int vowel -
cons
for (int i-0jics. size ()si**)
if(s[i]=' ')
contir
*o'||s[i]-- "u')
else if(s[il--'a'||s[4]--'e"||s[i]--"i'||s[i]--'o' ||s[i]--'u'||s[i]J--"A'||s[ij-- °E"||s[i]"1'lls[i]--
lse
consj