Docsity

lab reports and exercise, Lab Reports of Object Oriented Programming

Partial preview of the text

Download lab reports and exercise and more Lab Reports Object Oriented Programming in PDF only on Docsity!

INPUT OUTPUT:-

#include using namespace std; int main() { int r,s,cpool,spool; cin>>r>>s; cpool=3.14rr; spool=s*s; if(cpool>spool) cout<<"I Prefer Centre 1"; else cout<<"I Prefer Centre 2"; return 0; }

#include using namespace std; int main() { int aravspeed,aaronspeed,speeddiff; cin>>aravspeed>>aaronspeed; if(aravspeed>aaronspeed) speeddiff=aravspeed - aaronspeed; else speeddiff=aaronspeed - aravspeed; cout<<speeddiff; return 0; }

#include using namespace std; int main() { int n,dig=0,rem; cin>>n; while(n!=0) { rem=n%10; dig=dig*10+rem; n/=10; } while(dig!=0) { rem=dig%10; switch(rem) {

case 0: cout<<"Zero "; break; case 1: cout<<"One "; break; case 2: cout<<"Two "; break; case 3: cout<<"Three "; break; case 4: cout<<"Four "; break; case 5: cout<<"Five "; break; case 6: cout<<"Six "; break; case 7: cout<<"Seven "; break; case 8: cout<<"Eight "; break; case 9: cout<<"Nine "; break; };

num/=10; } if(result==number) cout<<"Part of Memorable Coin"; else cout<<"Not a Part of Memorable Coin"; return 0; } #include using namespace std; int main() { int nooffamilymembers,i,j; cin>>nooffamilymembers; for(i=nooffamilymembers;i>0;i--) {

for(j=0;j<i;j++) cout<<i<<" "; cout<<endl; } return 0; } #include using namespace std; int main() { int t,n,h,i,l=1,count; cin>>t; while(t--) { l=1; count=0; cin>>n; for(i=1;i<=n;i++) {

int M,initialtemp,finaltemp; float Q; cin>>M>>initialtemp>>finaltemp; Q=M(finaltemp - initialtemp)4184; cout<<""<<Q; return 0; } #include using namespace std; int main() { int husage,wfage,coupleavgage; cin>>husage>>wfage; coupleavgage=(husage+wfage)/2; cout<<"I am "<<husage<<endl<<"You are "<<wfage<<endl<<"We are around "<<coupleavgage; return 0;

#include using namespace std; int main() { int weightinearth; cin>>weightinearth; float weightinmoon; weightinmoon=0.166*weightinearth; cout<<weightinmoon; return 0;

// cout<<sum<<endl; else { max=b; sum+=a*b; // cout<<max<<endl; // cout<<sum<<endl; } } return sum; } }; int main(){ Happiness Purchase; cout<<Purchase.Meat(); }

#include #include <string.h> #include <stdio.h> using namespace std; double a[18][18], b[1 << 18]; int fun(int x) { int s = 0; while (x) { s += x & 1; x >>= 1; } return s; } int main() { if(0) cout<<"class Lake public:void survival() fish.survival();"; int n, i, r, t, j; cin >> n; for (i = 0; i < n; i++) for (j = 0; j < n; j++) scanf("%lf", &a[i][j]); memset(b, 0, sizeof(b)); b[(1 << n) - 1] = 1; for (i = (1 << n) - 1; i >= 0; i--) { int c = fun(i); c = c * (c - 1) / 2; for (r = 0; r < n; r++) if (i & (1 << r)) for (t = 0; t < n; t++)

if(fn.empty() || mn.empty() || ln.empty() ) { cout<<"Invalid Name"; } //cout<<"Invalid name"; exit(0) : else cout<<fn<<mn<<ln; } }; int main() { aadhaar Card; string fn,mn,ln; cin>>fn>>mn>>ln; Card.NameofCitizen(fn,mn,ln); return 0; }

#include using namespace std; class TollBooth { public: int cars; float tollcollected; TollBooth(){ cars=0; tollcollected=0; } void payingcar(double pay){ cars++; tollcollected+=pay; } void nonpayingcar(){ cars++; } void display(){ cout<<cars<<endl<<tollcollected<<endl; } }; int main() { TollBooth obj; char VehicleNo[10]; float TollAmt; int carpassed,i; cin>>carpassed; for(i=0;i<carpassed;i++) {

public: student(){name="Bhagavan";roll=1593;height=172.5;weight=60.4;} void getdata() { cin>>name>>roll>>height>>weight; } void displaydata(){ cout<<name<<" "<<roll<<" "<<height<<" "<<weight<<endl; } }; int main() { student s1,s2; s1.getdata(); s1.displaydata(); s2.displaydata(); return 0; } #include

using namespace std; class Friends { public:void Gifts(){ int i, n, a, b[50] = { 0 }; cin >> n; for (i = 1; i < n+1; i++) { cin >> a; b[a] = i; } for (i = 1; i < n+1; i++) cout<< b[i]<<" "; } }; int main() { Friends Sharing; Sharing.Gifts(); }