upsidedown

OOPS EXPT 1

Jan 20th, 2012
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.88 KB | None | 0 0
  1. #include<iostream.h>
  2. #include<conio.h>
  3. void swap(int *x,int *y)
  4. {
  5. *x=*x+*y;
  6. *y=*x-*y;
  7. *x=*x-*y;
  8. }
  9. int main()
  10. {
  11. clrscr();
  12. int a,b;
  13. cout<<"enter two nos"<<endl;
  14. cin>>a>>b;
  15. cout<<"the values before swapping a="<<a<<" b= "<<b<<endl;
  16. swap(&a,&b);
  17. cout<<"the values after swapping a="<<a<<" b= "<<b<<endl;
  18. getch();
  19. return 0;
  20. }
  21.  
  22.  
  23.  
  24.  
  25.  
  26. #include<iostream.h>
  27. #include<conio.h>
  28. int main()
  29. {
  30. clrscr();
  31. double p,t,r;
  32. cout<<"enter the principal, term and rate for simple interest calc\n";
  33. cin>>p>>t>>r;
  34. cout<<"the simple interest is ="<<(p*t*r)/100<<endl;
  35. getch();
  36. return 0;
  37. }
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46. #include<iostream.h>
  47. #include<conio.h>
  48. int main()
  49. {
  50. float s1,s2,s3,s4,s5;
  51. clrscr();
  52. cout<<"Enter 5 subject marks\n" ;
  53. cin>>s1>>s2>>s3>>s4>>s5;
  54. cout<<"marks are \n";
  55. cout<<"sub1\tsub2\tsub3\tsub4\tsub5\n";
  56. cout<<s1<<"\t"<<s2<<"\t"<<s3<<"\t"<<s4<<"\t"<<s5<<"\n";
  57. cout<<"the percentage is="<<(s1+s2+s3+s4+s5)/500<<endl;
  58. getch();
  59. return 0;
  60. }
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78. #include<iostream.h>
  79. #include<conio.h>
  80. #include<string.h>
  81.  
  82.  
  83. class student
  84. {
  85. float s1,s2,s3,s4,s5;
  86. char name[100];
  87. int rollno;
  88.  
  89. public:
  90. float p;
  91.  void get()
  92.  {
  93.   cout<<"\nEnter name and rollno\n";
  94.   cin>>name>>rollno;
  95.    cout<<"\nEnter 5 subject marks\n" ;
  96.    cin>>s1>>s2>>s3>>s4>>s5;
  97.    p=(float)((s1+s2+s3+s4+s5)/500*100);
  98.  }
  99.  void print()
  100.  {
  101.  cout<<name<<"\t"<<rollno<<"\t"<<s1<<"\t"<<s2<<"\t"<<s3<<"\t"<<s4<<"\t"<<s5<<"\t"<<p<<"\n";
  102.  }
  103.  
  104. };
  105.  
  106. int main()
  107. {
  108. int n;
  109. clrscr();
  110.  
  111. cout<<"Enter no of students ";
  112. cin>>n;
  113. student a[10],t;
  114. cout<<"\n enter details\n";
  115. for(int i=0;i<n;i++)
  116. {
  117.  a[i].get();
  118. }
  119. for(i=0;i<n;i++)
  120. {
  121. for(int j=0;j<n-i-1;j++)
  122. {
  123. if(a[j].p<a[j+1].p)
  124. {
  125.   t=a[j+1];
  126.   a[j+1]=a[j];
  127.   a[j]=t;
  128. }
  129.  
  130. }
  131. }
  132.  
  133.  
  134.  
  135.  
  136.  
  137. //clrscr();
  138.  
  139.  
  140. cout<<"name\trollno\tsub1\tsub2\tsub3\tsub4\tsub5\tpercentage\n";
  141. for(i=0;i<n;i++)
  142. {
  143. a[i].print();
  144. }
  145.  
  146.  
  147.  
  148. getch();
  149. return 0;
  150. }
Advertisement
Add Comment
Please, Sign In to add comment