Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- #include<conio.h>
- void swap(int *x,int *y)
- {
- *x=*x+*y;
- *y=*x-*y;
- *x=*x-*y;
- }
- int main()
- {
- clrscr();
- int a,b;
- cout<<"enter two nos"<<endl;
- cin>>a>>b;
- cout<<"the values before swapping a="<<a<<" b= "<<b<<endl;
- swap(&a,&b);
- cout<<"the values after swapping a="<<a<<" b= "<<b<<endl;
- getch();
- return 0;
- }
- #include<iostream.h>
- #include<conio.h>
- int main()
- {
- clrscr();
- double p,t,r;
- cout<<"enter the principal, term and rate for simple interest calc\n";
- cin>>p>>t>>r;
- cout<<"the simple interest is ="<<(p*t*r)/100<<endl;
- getch();
- return 0;
- }
- #include<iostream.h>
- #include<conio.h>
- int main()
- {
- float s1,s2,s3,s4,s5;
- clrscr();
- cout<<"Enter 5 subject marks\n" ;
- cin>>s1>>s2>>s3>>s4>>s5;
- cout<<"marks are \n";
- cout<<"sub1\tsub2\tsub3\tsub4\tsub5\n";
- cout<<s1<<"\t"<<s2<<"\t"<<s3<<"\t"<<s4<<"\t"<<s5<<"\n";
- cout<<"the percentage is="<<(s1+s2+s3+s4+s5)/500<<endl;
- getch();
- return 0;
- }
- #include<iostream.h>
- #include<conio.h>
- #include<string.h>
- class student
- {
- float s1,s2,s3,s4,s5;
- char name[100];
- int rollno;
- public:
- float p;
- void get()
- {
- cout<<"\nEnter name and rollno\n";
- cin>>name>>rollno;
- cout<<"\nEnter 5 subject marks\n" ;
- cin>>s1>>s2>>s3>>s4>>s5;
- p=(float)((s1+s2+s3+s4+s5)/500*100);
- }
- void print()
- {
- cout<<name<<"\t"<<rollno<<"\t"<<s1<<"\t"<<s2<<"\t"<<s3<<"\t"<<s4<<"\t"<<s5<<"\t"<<p<<"\n";
- }
- };
- int main()
- {
- int n;
- clrscr();
- cout<<"Enter no of students ";
- cin>>n;
- student a[10],t;
- cout<<"\n enter details\n";
- for(int i=0;i<n;i++)
- {
- a[i].get();
- }
- for(i=0;i<n;i++)
- {
- for(int j=0;j<n-i-1;j++)
- {
- if(a[j].p<a[j+1].p)
- {
- t=a[j+1];
- a[j+1]=a[j];
- a[j]=t;
- }
- }
- }
- //clrscr();
- cout<<"name\trollno\tsub1\tsub2\tsub3\tsub4\tsub5\tpercentage\n";
- for(i=0;i<n;i++)
- {
- a[i].print();
- }
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment