C++ Sample Program

  • Uploaded by: Lakshminarayanan
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View C++ Sample Program as PDF for free.

More details

  • Words: 808
  • Pages: 9
C++ PROGRAM #include #include #include<math.h> #include<process.h> int se,c=0; float hj,vj,h1,h2,x1,x2,u1,u2,d,sam,t1,t2;

void pass(void) { char waste; char a[12]={"ballistics"}; char b[12]; int w=0; for(w=0;w<3;w++) { cout<<"enter password\n"; cin.getline(b,11); c=0; for(int i=0;i<11;i++) { if(a[i]!=b[i]) { cout<<"\nwrong password\n"; c=25; break; } else c++; } if(w==1 && c==25) cout<<"\nlast try\n";

}

if(c==i) { cout<<"\nWelcome to project BALLISTICS\nThis program enables easy"; cout<<" calculation of\nparameters related to ballistics\n\n"; cout<<"They include following defence categories\n\n"; break; }

if(w==3&&c==25) { cout<<"programme closing due to security threat\n"; E:cout<<"enter any character\n"; cin>>waste; exit(0); } }

void select(void) { cout<<"\t\tAPPLICATION \tCATEGORY NO\n\n"; cout<<"\t\taerial bombing\t\t1\n"; cout<<"\t\tmissile launching\t2\n"; cout<<"\t\tanti-missile \t\t3\n"; cout<<"\t\tshell firing \t\t4\n"; cout<<"\t\texit \t\t5\n"; }

void select1(void) { cout<<endl; cout<<"This enables to calculate the required height or velocity of a jet\n"; cout<<"to hit a target at a given distance from it using a shell\n"; cout<<"The two cases are given below\n\n"; cout<<"CASE NO:S\t\tTO FIND\t\tNEEDED DATA\n\n"; cout<<"case no:1\t\theight \t\tdistance to target,velocity\n"; cout<<"case no:2\t\tvelocity \tdistance to target,height\n\n"; cout<<"case no:3\t\t\t\texit\n"; cout<<"\n(to go to main menu enter 100 as case number)\n"; }

void select2(void) { cout<<endl; cout<<"This enables to find height or velocity of projection of a missile\n"; cout<<"to attain the desired range. The two cases are given below\n"; cout<<"choose the required by giving the case number\n\n"; cout<<"\t\tCASE NO:S\t\tTO FIND\t\tNEEDED DATA\n\n"; cout<<"\t\tcase no:1\t\theight \t\tvelocity,range\n"; cout<<"\t\tcase no:2\t\tvelocity \theight,range\n\n"; cout<<"\t\tcase no:3\t\t\t\texit\n"; cout<<"\n(to go to main menu enter 100 as case number)\n"; }

void select3(void) { cout<<endl; cout<<"This enables to find height of projection of an anti-missile\n"; cout<<"Five cases are given below ,each with different set of input data\n"; cout<<"Please choose the required by entering method no:\n\n";

cout<<"\t\tCASE NO:S\t\tNEEDED DATA\n\n"; cout<<"\t\tcase no:1\t\th2,t1,t2\n"; cout<<"\t\tcase no:2\t\th2,x1,x2,u1,u2\n"; cout<<"\t\tcase no:3\t\th2,x1,s,u1,u2\n"; cout<<"\t\tcase no:4\t\td,x1,s,u1,u2\n"; cout<<"\t\tcase no:5\t\th2,x1,d,u1,s\n\n"; cout<<"\t\tcase no:6\t\t\texit\n"; cout<<"where,\nh2-height of enemies missile (in mts)\n"; cout<<"t2-time taken by enemies missile to reach point of collission (in s)\n"; cout<<"t1-time taken by anti-missile to reach point of collission (in s)\n"; cout<<"u1-velocity of anti-missile (in m/s)\n"; cout<<"u2-velocity of missile (in m/s)\n"; cout<<"x1-distance of point of collission from our launch pad (in mts)\n"; cout<<"x2-distance of point of collission from enemy's launch pad (in mts)\n"; cout<<"s- distance b/w two launch pads (in mts)\n"; cout<<"d-distance of enemy's target from our launch pad\n"; cout<<"\n(to go to main menu enter 100 as case number)\n"; }

void select4(void) { cout<<endl; cout<<"This helps to find the time or angle of projection of a shell\n"; cout<<"which can hit a flying object at a specific height moving with\n"; cout<<"a specific average velocity (for specific velocity of projection)\n"; cout<<"The two cases are given below, choose the required case\n\n"; cout<<"\t\tCASE NO:S\tTO FIND\t\t\t\tNEEDED DATA\n\n"; cout<<"\t\tcase no:1\ttime taken to reach target\tv,u,hs\n"; cout<<"\t\tcase no:2\tangle of projection\t \tv,u,hs\n\n"; cout<<"\t\tcase no:3\t\texit\n"; cout<<"where,\n"; cout<<"u-velocity of projection of shell\n"; cout<<"v-velocity of flying object\n"; cout<<"h-height of flying object\n"; cout<<"\n(to go to main menu enter 100 as case number)\n"; }

float ar1(float xar1) { if(se==1) cout<<"enter velocity of jet\n"; if(se==2) cout<<"enter average velocity of projection of missile\n"; cin>>vj; hj=(xar1/vj)*sqrt(9.806/2); return hj;

}

float ar2(float xar2) { if(se==1) cout<<"enter height of jet\n"; if(se==2) cout<<"enter average heightt of projection of missile\n"; cin>>hj; vj=xar2*sqrt(9.806/(2*hj)); return vj; }

float am1(void) { cout<<"enter h2,t1,t2\n"; cin>>h2>>t1>>t2; h1=h2+((9.806/2)*((pow(t1,2))-(pow(t2,2))));/*(9.806/2)*((t1*t1)-(t2*t2))*/ return h1; } float am2(void) { cout<<"enter h2,x1,x2,u1,u2\n"; cin>>h2>>x1>>x2>>u1>>u2; h1=h2+((9.806/2)*(((x1*x1)/(u1*u1))-((x2*x2)/(u2*u2)))); return h1; }

float am3(void) { cout<<"enter h2,x1,s,u1,u2\n"; cin>>h2>>x1>>sam>>u1>>u2; h1=h2+((9.806/2)*(((x1*x1)/(u1*u1))-(((sam-x1)*(sam-x1))/(u2*u2)))); return h1;

}

float am4(void) { float j,k; cout<<"enter d,x1,s,u1,u2\n"; cin>>d>>x1>>sam>>u1>>u2; j=d-x1; k=(d+x1)-(2*sam); h1=(9.806/2)*(((x1*x1)/(u1*u1))+((j*k)/(u2*u2))); return h1; }

float am5(void) { float l,p,q,r; cout<<"enter h2,d,s,u1,x1\n"; cin>>h2>>d>>sam>>u1>>x1; p=(9.806/2)*((x1*x1)/(u1*u1)); q=d-x1; r=(d+x1)-(2*sam); l=(sam-d)*(sam-d); h1=p+(h2*q*r/l); return h1; } void sh(int s4s) { float us,uy,vs,hs,disc,t; cout<<"enter u,v & h\n"; cin>>us>>vs>>hs; if(us
{ t=(uy-sqrt(disc))/9.806; if(s4s==1) cout<<"REQUIRED TIME="<>ds; float ssh=vs*t; float xsh=ds+ssh; float q; q=atan((hs/xsh)+((9.086/2)*(xsh/(vs*vs)))); cout<<"REQUIRED ANGLE="<
} }

void main() { clrscr(); int s1,s2,s3,s4; float m,ar,xm,xj,h; char rep,ch; cout<<"do you want to open project ballistics (y/n)\n"; cin>>rep;cin.get(ch); while(rep=='y'||rep=='Y') { pass(); if(c!=25) { m:select(); cout<<"enter the category no:\n"; cin>>se; if(se==1) { select1(); cout<<"enter case number\n"; cin>>s1; if(s1==100)

goto m; if(s1<1 || s1>3) { cout<<"inalid entry\n"; goto l; } if(s1==3) goto l; cout<<"enter distance to target from jet (in mts)\n"; cin>>xj; if(s1==1) { ar=ar1(xj); cout<<"REQUIRED HEIGHT="<<ar<<" mts"<<endl; } if(s1==2) { ar=ar2(xj); cout<<"REQUIRED VELOCITY="<<ar<<" mts/s"<<endl; } } if(se==2) { select2(); cout<<"enter case number\n"; cin>>s2; if(s2==100) goto m; if(s2<1 || s2>3) { cout<<"invalid entry\n"; goto l; } if(s2==3) goto l; cout<<"enter the range\n"; cin>>xm; if(s2==1) { m=ar1(xm); cout<<"REQUIRED HEIGHT="<<m<<" mts"<<endl; } if(s2==2) { m=ar2(xm); cout<<"REQUIRED VELOCITY="<<m<<" mts/s"<<endl;

} } if(se==3) { select3(); cout<<"method number\n"; cin>>s3; if(s3==100) goto m; if(s3==1) h=am1(); if(s3==2) h=am2(); if(s3==3) h=am3(); if(s3==4) h=am4(); if(s3==5) h=am5(); if(s3==6) goto l; if(s3<1 || s3>6) { cout<<"invalid entry\n"; goto l; } cout<<"REQUIRED HEIGHT="<>s4; if(s4==100) goto m; if(s4<1 || s4>3) { cout<<"invalid entry\n"; goto l; } if(s4==3)

goto l; sh(s4); } if(se==5) goto l; if(se<1 || se>5) { cout<<"invalid entry\n"; goto l; } } l:cout<<"do you want to continue (y/n)\n"; cin>>rep; cin.get(ch); } getch(); }

Related Documents

C++ Sample Program
May 2020 4
C Program
May 2020 12
Auction Program Sample 2
November 2019 16
Auction Program Sample 1
November 2019 17
Sample Safety Program
June 2020 8

More Documents from "Neal Lester"