Sie sind auf Seite 1von 12

PROGRAMS OF SIR S.H.

RIZVI
01.LIMITS
#include<conio.h> #include<iostream.h> #include<math.h> void main (void) { clrscr(); int low,up; float fx; cout<<"Enter lower Limit of Function"<<endl; cin>>low; cout<<"Enter upper limit of function"<<endl; cin>>up; for (int x=low;x<=up;x++) { fx=pow(x,2)+2*sin(x); cout<<" For x= "<<x<<"f(x)= "<<fx<<endl; } getch(); }

2. FINDING OF EVEN ODD NUMBERS


#include<conio.h> #include<iostream.h> #include<math.h> void main (void) { clrscr(); int st,ed,even=0,odd=0; cout<<"Enter starting number"<<endl; cin>>st; cout<<"Enter ending number"<<endl; cin>>ed;

for ( int i=st;i<=ed;i++) { if (i%2==0) { cout<<i<<" is an even number"<<endl; } else { cout<<i<< "is an odd number"<<endl; }

} getch(); }

3. TOTAL EVEN ODD NUMBERS


#include<conio.h> #include<iostream.h> #include<math.h> void main (void) { clrscr(); int st,ed,even=0,odd=0; cout<<"Enter starting number"<<endl; cin>>st; cout<<"Enter ending number"<<endl; cin>>ed;

for ( int i=st;i<=ed;i++) { if (i%2==0) { cout<<i<<" is an even number"<<endl; even=even+1; } else { cout<<i<< "is an odd number"<<endl; odd=odd+1;

} } cout<<"Total "<<even<<" even numbers"<<endl; cout<<"Total "<<odd <<"odd numbers"<<endl;

getch(); }

4. #include<conio.h> #include<iostream.h> #include<math.h> void main (void) { clrscr(); int a,b,c,dis; cout<<"Enter value of a"<<endl; cin>>a; cout<<"Enter value for b"<<endl; cin>>b; cout<<"Enter value for c"<<endl; cin>>c; dis=pow(b,2)-4*a*c; if (dis==0) { cout<<" Roots are real and equal"<<endl;

} if(dis>0) { cout<<"roots are real and unequal"<<endl; } if (dis<0) { cout<<"Roots are img and unequal"<<endl; } getch(); }

5. MARKS SHEET
#include<conio.h> #include<iostream.h> #include<math.h> void main (void) { clrscr(); float m,p,c,e,u,sum,per,avg; cout<<"Enter maths marks"<<endl; cin>>m; cout<<"Enter Physics marks"<<endl; cin>>p; cout<<"Enter chemistry marks"<<endl; cin>>c;

cout<<"Enter english marks"<<endl; cin>>e; cout<<"Enter urdu marks"<<endl; cin>>u; sum=m+p+c+e+u; avg=sum/5.0; per=(sum/500.0)*100; cout<<"Sum = "<<sum<<endl; cout<<"Average = "<<avg<<endl; cout<<"Percentage = "<<per<<"%"<<endl; if (per<60) { cout<<"Grade = F"<<endl; } if (per>=60 && per<70) { cout<<"Grade = C"<<endl; } if (per >=70 && per <80) { cout<<"Grade = B"<<endl; } if (per>=80) { cout<<"Grade = A"<<endl; }

getch(); }

6. MENU PROGRAMME
#include<iostream.h> #include<stdio.h> #include<conio.h> #include<dos.h> #include<math.h> void main(void) { start: clrscr(); cout<<"***********************************************"<<endl; cout<<"** Press '1' for Fisr Equation of motion **"<<endl; **"<<endl; **"<<endl;

cout<<"** Press '2' for second equation of motion cout<<"** Press '3' for third equation of motion cout<<"** Press '4' for Table

**"<<endl; **"<<endl;

cout<<"** Press '5' for even and odd numbers cout<<"** Press '6' for exit

**"<<endl;

cout<<"***********************************************"<<endl; cout<<"Enter your choice [1-6]"<<endl; int ch; cin>>ch; float vi,s,vf,a,t;

if (ch==1) {

clrscr(); cout<<"Enter initial velocity"<<endl;

cin>>vi; cout<<"Enter acceratio "<<endl; cin>>a; cout<<"Enter time"<<endl; cin>>t; vf=vi+a*t; cout<<"Calculating..."<<endl; delay(3000); cout<<"Final velocity is "<<vf<<" m/s"<<endl; getch(); goto start; } if (ch==2) { clrscr(); cout<<"Enter initial velocity"<<endl; cin>>vi; cout<<"Enter acceration "<<endl; cin>>a;

cout<<"Enter time"<<endl; cin>>t; s=vi*t+(1/2)*a*pow(t,2); cout<<" Distance is "<< s<<" m"<<endl; getch(); goto start; } if (ch==3) { clrscr(); cout<<"Enter initial velocity"<<endl; cin>>vi; cout<<"Enter final velocity "<<endl; cin>>vf; s=pow(vf,2)-pow(vi,2); cout<<" 2as ="<< s<<endl; getch(); goto start; } if (ch==4) { clrscr(); cout<<"Enter you number"<<endl; int n,st,ed; cin>>n;

cout<<"enter starting number"<<endl; cin>>st; cout<<"enter ending number "<<endl; cin>>ed; clrscr(); cout<<"***************"<<endl; for ( int j=st;j<=ed;j++) { cout<<"**"<<n<<" x "<<j<<" = "<<n*j<<"**"<<endl; delay(1000); } cout<<"***************"<<endl;

getch(); goto start; }

if (ch==5) { clrscr(); int st,ed,e=0,o=0; cout<<"enter starting number"<<endl; cin>>st; cout<<"enter ending number "<<endl; cin>>ed;

clrscr(); for ( int j=st;j<=ed;j++) { if ( j%2==0) {cout<<j <<" is an even number"<<endl; e++; } else { cout<<j<<" is an odd number"<<endl; o++; }

} cout<<"total "<<e<<" even numbers"<<endl; cout<<"total "<<o<<" odd numbres"<<endl; getch(); goto start; } if (ch==6) { ag: cout<<" Do you want to Cont: [y/n]"<<endl; char choice; cin>>choice;

if (choice=='y'|| choice=='Y') { goto start; } if (choice=='n'|| choice=='N') { cout<<"Good Bye"<<endl; } else { cout<<"Invalid entry"<<endl; goto ag; } } getch(); }

Das könnte Ihnen auch gefallen