C or C++ codefor a scientific or graphing calculator
i need the code for a scientific or graphing calculator in c or c++. please help!!
and also suggest me with a topic for embedded technology
Member • Oct 31, 2009
Please post whatever you have tried to code. The CEans will help you.Dhrutihey guys!!
i need the code for a scientific or graphing calculator in c or c++. please help!!
and also suggest me with a topic for embedded technology
Administrator • Oct 31, 2009
Member • Nov 1, 2009
#include<iostream.h> #include<process.h> #include<math.h> #include<conio.h> #include<graphics.h> #include<dos.h> #include<stdio.h> #include<stdlib.h> class figurecal { public: char ch1,ch,ch2,ch3,ch4; char ans; int a,b,c,res,cir,cho,cu,cub,con,cyl,sph,y0,l; int color; int bottom1; int midx, midy; int stangle , endangle; int xradius,yradius; int x1,y1; int left,top,right,bottom; int a1,a2,a3,a4,b1,b2,b3,b4; float x,y,z,d,w,side,area,pm,len,bre,rad,circum; float sector,segment,rho,g,par,base,h,angle,arc,rad1,rad2,sh; float d1,d2,vol; float root1,root2,disc,s; long double lo; }; // ** // float addi(int a,int b); float sub(int a,int b); float mult(int a,int b); float divi(int a,int b); float rem(int a ,int b); float disc(int a,int b,int c); float roots(int a,int b,int disc); // ** // float tri_roc(int a,int b,int c,int d); float c_a1(int a); float c_a2(int a); float area(int a,int b); float area(int a,int b,int c); float peri(int a,int b); float peri(int a,int b,int c); float diag(int a,int b); float circum1(int a); float circum2(int a); float rh_side(int a,int b); float trap_area(int a,int b,int c); float circ_sec(int a,int b); float circ_arc(int a,int b); // ** // float cu_vol(int a,int b,int c); float cu_sa(int a,int b,int c); float cu_diag(int a,int b,int c); float cyl_vol(int a,int b); float cyl_sa(int a,int b); float cyl_csa(int a,int b); float ho_cyl_vol(int a1,int a2,int b); float ho_cyl_sa(int a1,int a2,int b); float ho_cyl_csa(int a1,int a2,int b); float con_vol(int a,int b); float con_sa(int a,int b); float con_csa(int a,int b); float sph_vol(int a); float sph_sa(int a); float sem_sph_sa(int a); float sem_sph_vol(int a); float sem_sph_csa(int a); void main() { clrscr(); figurecal o; int gdriver=DETECT,gmode; initgraph(&gdriver,&gmode,"c:\\tc\\bin\\bgi"); o.color=0; o.bottom1=0; o.stangle = 0, o.endangle = 360; o.xradius = 280, o.yradius = 180; delay(1100); for(;o.bottom1<=470;o.bottom1++) { setcolor(12); delay(6); rectangle(0,10,650,o.bottom1); } o.midx = getmaxx() / 2; o.midy = getmaxy() / 2; setcolor(10); setbkcolor(12); for(o.x1=160,o.y1=0;o.y1<190;o.y1++,o.color++) { delay(12); cleardevice(); setcolor(o.color); settextstyle(4,0,7); outtextxy(o.x1,o.y1,"WELCOME"); } for(;o.xradius>131,o.yradius>81;o.xradius--,o.yradius--,o.color++) { setcolor(o.color); ellipse(o.midx, o.midy, o.stangle, o.endangle,o.xradius, o.yradius); delay(20); cleardevice(); settextstyle(4,0,7); outtextxy(160,190,"WELCOME"); } setbkcolor(4); setcolor(14); settextstyle(4,0,7); outtextxy(160,190,"WELCOME"); delay(3400); clrscr(); setbkcolor(4); settextstyle(4,0,4); outtextxy(80,30,"Project On:"); for( o.w=15;o.w>0;o.w--) { settextstyle(4,0,7); setcolor(o.w); delay(300); outtextxy(50,100,"Scientific Calculator"); } setcolor(14); sound(900); delay(300); nosound(); sound(1100); delay(270); nosound(); sound(1200); settextstyle(6,0,2); outtextxy(50,400,"Guided by: Mr.Sanjay Ojha sir"); delay(270); nosound(); delay(300); sound(1200); delay(270); nosound(); sound(1100); delay(180); nosound(); sound(900); delay(270); nosound(); sound(800); delay(270); nosound(); delay(200); sound(800); delay(270); nosound(); settextstyle(6,0,2); outtextxy(50,430,"Project by: MADHU M P .. [EMAIL="madhumurundi@gmai.com"]madhumurundi@gmai.com[/EMAIL]"); delay(500); sound(1200); delay(270); nosound(); delay(200); sound(1200); delay(270); nosound(); sound(1100); delay(270); nosound(); sound(900); delay(270); nosound(); sound(800); delay(270); nosound(); delay(200); sound(800); delay(270); nosound(); delay(400); sound(900); delay(230); nosound(); sound(300); delay(200); nosound(); getch(); cout<<"\n\n\n\n\n"; again: cleardevice(); setcolor(14); setbkcolor(5); settextstyle(6,0,4); outtextxy(140,45,"Select one of the following"); cout<<"\n\n\n\n\t\t1)Basic calculations(+,-..) \n\n\t\t2)2-D figures \n\n\t\t3)3-D figures\n\n\t\t4)Other trignometric & log functions\n\n\t\t5)Exit"; cout<<"\n\n\n\n\n\t\tPlease enter your choice: "; cin>>o.ch; clrscr(); cleardevice(); switch(o.ch) { case '1': //basic: settextstyle(6,0,4); outtextxy(70,50,"Welcome to basic arithmetic calculations"); cout<<"\n\n\n\n\n\n\n\t\t1)Addition\n\n\t\t2)Substraction\n\n\t\t3)Multiplication\n \n\t\t4)Division\n\n\t\t5)Remainder\n\n\t\t6)Roots of quadratic equation \n\n\t\t7)Exit\n\n\t\t Enter your choice:"; cin>>o.ch1; clrscr(); cleardevice(); switch(o.ch1) { case'1': settextstyle(10,0,9); outtextxy(500,20,"+"); settextstyle(6,0,5); outtextxy(120,30,"Addition"); cout<<"\n\n\n\n\n\n\n\t\tEnter two numbers(use space to seperate no.s):"; cin>>o.a>>o.b; o.res=addi(o.a,o.b); cout<<"\n\n\n\t\tThe sum is "<<o.res; getch(); break; case'2':settextstyle(6,0,5); outtextxy(120,30,"Substration"); cout<<"\n\n\n\n\n\n\n\t\tEnter two numbers(use space to seperate no.s):"; cin>>o.a>>o.b; o.res=sub(o.a,o.b); cout<<"\n\n\t\t The difference is"<<o.res; getch(); break; case'3':settextstyle(6,0,5); outtextxy(120,30,"Multiplation"); cout<<"\n\n\n\n\n\n\n\t\tEnter two numbers(use space to seperate no.s):"; cin>>o.a>>o.b; o.res=mult(o.a,o.b); cout<<"\n\t\t The product is "<<o.res; getch(); goto repeat; //break; case'4':settextstyle(6,0,5); outtextxy(120,30,"Division"); cout<<"\n\n\n\n\n\n\n\t\tEnter two numbers(use space to seperate no.s):"; cin>>o.a>>o.b; if(o.b==0) { cout<<"\n\t\t Divide by zero error!!"; goto repeat; } else { o.res=divi(o.a,o.b); cout<<"\n\t\t The result is "<<o.res; getch();} break; case'5': settextstyle(10,0,5); outtextxy(500,20,"%"); {settextstyle(6,0,5); outtextxy(120,30,"Remainder"); cout<<"\n\n\n\n\n\n\n\t\tEnter two numbers(use space to seperate no.s):"; cin>>o.a>>o.b; if(o.b==0) { cout<<"\n\t\t Divide by zero error!!"; goto repeat; } else { o.res=rem(o.a,o.b); cout<<"\n\t\t The result is "<<o.res; getch(); } break; case'6': settextstyle(6,0,5); outtextxy(120,30,"Roots of quadratic equation"); cout<<"\n\n\n\n\n\n\n\t\tEnter three no.s a,b&c of \n\n\t\tax^2 + bx + c:\n\n\t\t(use space to seperate no.s)"; cin>>o.a>>o.b>>o.c; if(o.a==0) {cout<<"\n\t\tValue of a should not be zero"; getch(); goto repeat; } else { o.disc=disc(o.a,o.b,o.c); if(o.disc>0) { o.root1=roots(o.a,o.b,o.disc); o.root2=roots(o.a,o.b,o.disc); cout<<"\n\t\tRoots are real and unequal\n\t\t"; cout<<"Root1 = "<<o.root1; cout<<"\n\t\tRoot2 = "<<o.root2<<endl<<endl<<endl; getch(); break; } else if(o.disc==0) {o.root1=-o.b/(2*o.a); o.root2=o.root1; cout<<"\n\n\t\tRoots are real and equal"; cout<<"\n\t\tRoot1 = "<<o.root1; cout<<"\n\t\tRoot2 = "<<o.root2; getch(); break; } else cout<<"\n\n\t\tRoots are complex and imaginary"; } break; case'7': goto repeat; } }//end of switch ch1 break; case'2'://cleardevice(); setbkcolor(5); settextstyle(6,0,4); outtextxy(120,30,"Welcome to 2D figures"); cout<<"\n\n\n\n\n\n\n\t\t1)Square\t\t2)Rectangle\n\n\t\t3)Triangle\t\t4)Parallelogram\n\n\t\t5)Circle\t\t6)Semi-Circle\n\n\t\t7)Rhombus\t\t8)Trapezium\n\n\t\t9)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.ch2; clrscr(); cleardevice(); switch(o.ch2) { case'1': for( o.a1=100,o.a2=200,o.a3=200,o.a4=100,o.b1=200,o.b2=200,o.b3=300,o.b4=300;o.a1<475,o.a2<575,o.a3<525,o.a4<425;o.a1++,o.a2++,o.a3++,o.a4++) { cleardevice(); line(o.a1,o.b1,o.a2,o.b2); line(o.a2,o.b2,o.a3,o.b3); line(o.a1,o.b1,o.a4,o.b4); line(o.a3,o.b3,o.a4,o.b4); delay(10); } settextstyle(6,0,5); outtextxy(130,30,"Square"); cout<<"\n\n\n\n\n\n\t\t1)Area\n\n\t\t2)Perimeter\n\n\t\t3)Diagonal\n\n\t\t4)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.cho; if(o.cho==1) { cout<<"\n\t\tEnter the length of side:"; cin>>o.side; o.area=area(o.side,o.side); cout<<"\n\t\tThe area is "<<o.area; getch(); break; } else if(o.cho==2) { cout<<"\n\t\tEnter the length of side:"; cin>>o.side; o.pm=peri(o.side,o.side); cout<<"\n\t\tThe perimeter is "<<o.pm; getch(); break; } else if(o.cho==3) { cout<<"\n\t\tEnter the side:"; cin>>o.side; o.d=diag(o.side,o.side); cout<<"\n\t\tThe length of diagonal is "<<o.d; getch(); break; } else if(o.cho==4) goto repeat; break; case'2': for(o.a1=150,o.a2=300,o.a3=300,o.a4=150,o.b1=200,o.b2=200,o.b3=270,o.b4=270;o.a1<475,o.a2<575,o.a3<525,o.a4<425;o.a1++,o.a2++,o.a3++,o.a4++) { cleardevice(); line(o.a1,o.b1,o.a2,o.b2); line(o.a2,o.b2,o.a3,o.b3); line(o.a1,o.b1,o.a4,o.b4); line(o.a3,o.b3,o.a4,o.b4); delay(5); } setcolor(14); settextstyle(6,0,5); outtextxy(130,30,"Rectangle"); cout<<"\n\n\n\n\n\n\t\t1)Area\n\n\t\t2)Perimeter\n\n\t\t3)Diagonal\n\n\t\t4)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.cho; if(o.cho==1) { cout<<"\n\n\t\tEnter the length and breadth:"; cin>>o.len>>o.bre; o.area=area(o.len,o.bre); cout<<"\n\n\t\tThe area is "<<o.area; getch(); break; } else if(o.cho==2) { cout<<"\n\n\t\tEnter the length and breadth:"; cin>>o.len>>o.bre; o.pm=peri(o.len,o.bre); cout<<"\n\n\t\tThe perimeter is "<<o.pm; getch(); break; } else if(o.cho==3) { cout<<"\n\n\t\tEnter the length and breadth:"; cin>>o.len>>o.bre; o.d=diag(o.len,o.bre); cout<<"\n\n\t\tThe length of diagonal is "<<o.d; getch(); break; } else if(o.cho==4) goto repeat; break; case'3': for(o.a1=80,o.a2=150,o.a3=0,o.b1=250,o.b2=350,o.b3=350;o.a1<450,o.a2<500,o.a3<350;o.a1++,o.a2++,o.a3++) { cleardevice(); line(o.a1,o.b1,o.a2,o.b2); line(o.a2,o.b2,o.a3,o.b3); line(o.a1,o.b1,o.a3,o.b3); delay(5); } settextstyle(6,0,5); outtextxy(130,30,"Triangle"); cout<<"\n\n\n\n\n\n\t\t1)Area\t\t\t2)Perimeter\n\n\t\t3)Radius of incircle\t4)Radius of cimcumcircle\n\n\t\t5)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.cho; if(o.cho==1) { cout<<"\n\n\t\tEnter the sides a,b &c:"; cin>>o.x>>o.y>>o.z; o.area=area(o.x,o.y,o.z); cout<<"\n\n\t\tThe area is "<<o.area; getch(); break; } else if(o.cho==2) { cout<<"\n\n\t\tEnter the sides a,b &c:"; cin>>o.a>>o.b>>o.c; o.pm=peri(o.a,o.b,o.c); cout<<"\n\n\t\tThe perimeter is "<<o.pm; getch(); break; } else if(o.cho==3) { cout<<"\n\n\t\tEnter the sides a,b &c:"; cin>>o.x>>o.y>>o.z; o.s=(o.x+o.y+o.z)/2; o.area=area(o.x,o.y,o.z); o.rad= o.area/o.s; cout<<"\n\n\t\tThe radius of incircle is "<<o.rad; getch(); break; } else if(o.cho==4) { cout<<"\n\n\t\tEnter the sides a,b &c:"; cin>>o.x>>o.y>>o.z; o.s=(o.x+o.y+o.z)/2; o.area=area(o.x,o.y,o.z); o.rad=tri_roc(o.x,o.y,o.z,o.area); cout<<"\n\n\t\tThe radius of circumcircle is "<<o.rad; getch(); break; } else goto repeat; case'4': for(o.a1=100,o.a2=232,o.a3=180,o.a4=50,o.b1=200,o.b2=200,o.b3=270,o.b4=270;o.a1<425,o.a2<525,o.a3<475,o.a4<375;o.a1++,o.a2++,o.a3++,o.a4++) { cleardevice(); line(o.a1,o.b1,o.a2,o.b2); line(o.a2,o.b2,o.a3,o.b3); line(o.a1,o.b1,o.a4,o.b4); line(o.a3,o.b3,o.a4,o.b4); delay(5); } settextstyle(6,0,5); outtextxy(130,30,"Parallelogram"); cout<<"\n\n\n\n\n\n\t\t1)Area\t\t2)Perimeter\n\n\t\t3)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.cho; if(o.cho==1) { cout<<"\n\n\t\tEnter the length of base and height:"; cin>>o.base>>o.h; o.area=area(o.base,o.h); cout<<"\n\n\t\tThe area is"<<o.area; getch(); break; } else if(o.cho==2) { cout<<"\n\n\t\tEnter the length and breadth:"; cin>>o.len>>o.bre; o.pm=peri(o.len,o.bre); cout<<"\n\n\t\tThe perimeter is"<<o.pm; getch(); break; } else if(o.cho==3) goto repeat; break; case'5': for(o.rad=0;o.rad<80;o.rad++) { cleardevice(); circle(450,300,o.rad); delay(5); } settextstyle(6,0,5); outtextxy(130,30,"Circle"); cout<<"\n\n\n\n\n\n\t\t1)Area\t\t\t\t2)Circumference\n\n\t\t3)Length of an arc\t\t4)Area of sector\n\n\t\t5)Area of segment\t\t6)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.cho; if(o.cho==1) { cout<<"\n\n\t\tEnter the radius of circle:"; cin>>o.rad; o.area=c_a1(o.rad); cout<<"\n\n\t\tThe area is "<<o.area; getch(); break; } else if(o.cho==2) { cout<<"\n1\n\t\tEnter the radius of circle:"; cin>>o.rad; o.circum= circum1(o.rad); cout<<"\n\n\t\tThe circumference is "<<o.circum; getch(); break; } else if(o.cho==3) { cout<<"\n\n\t\tEnter the radius and angle:"; cin>>o.rad>>o.angle; o.arc=circ_arc(o.rad,o.angle);// cout<<"\n\n\t\tThe length of arc is "<<o.arc; getch(); break; } else if(o.cho==4) { cout<<"\n\n\t\tEnter the radius and angle:"; cin>>o.rad>>o.angle; o.sector=circ_sec(o.rad,o.angle); cout<<"\n\n\t\tThe area of sector is "<<o.sector; getch(); break; } else if(o.cho==5) { cout<<"\n\n\t\tEnter the radius and angle:"; cin>>o.rad>>o.angle; o.sector=circ_sec(o.rad,o.angle); o.area=0.5*o.rad*o.rad*sin(o.angle); o.segment= o.sector-o.area; cout<<"\n\n\t\tThe area of segment is "<<o.segment; getch(); break; } break; case'6': for(o.a1=0;o.a1<181;o.a1++) { cleardevice(); setfillstyle(EMPTY_FILL,12); pieslice(450,300,0,o.a1,80); delay(10); } settextstyle(6,0,5); outtextxy(130,30,"Semi Circle"); cout<<"\n\n\n\n\n\n\t\t1)Area\t\t\t\t2)Circumference\n\n\t\t3)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.cho; if(o.cho==1) { cout<<"\n\n\t\tEnter the radius of semi-circle:"; cin>>o.rad; o.area=(3.14*o.rad*o.rad)/2; cout<<"\n\n\t\tThe area is "<<o.area; getch(); break; } else if(o.cho==2) { cout<<"\n\n\t\tEnter the radius of semi-circle:"; cin>>o.rad; o.circum=5.14*o.rad; cout<<"\n\n\t\tThe circumference is "<<o.circum; getch(); break; } else if(o.cho==3) goto repeat; break; case'7': for(o.a1=100,o.a2=200,o.a3=180,o.a4=80,o.b1=200,o.b2=200,o.b3=270,o.b4=270;o.a1<425,o.a2<525,o.a3<475,o.a4<380;o.a1++,o.a2++,o.a3++,o.a4++) { cleardevice(); line(o.a1,o.b1,o.a2,o.b2); line(o.a2,o.b2,o.a3,o.b3); line(o.a1,o.b1,o.a4,o.b4); line(o.a3,o.b3,o.a4,o.b4); delay(10); } settextstyle(6,0,5); outtextxy(130,30,"Rhombus"); cout<<"\n\n\n\n\n\n\t\t1)Area\t\t2)Perimeter\n\n\t\t3)Side\t\t4)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.cho; if(o.cho==1) { cout<<"\n\n\t\tEnter the length of diagonals:"; cin>>o.d1>>o.d2; o.area=0.5*o.d1*o.d2; cout<<"\n\n\t\tThe area is "<<o.area; getch(); break; } else if(o.cho==2) { cout<<"\n\n\t\tEnter the length of side:"; cin>>o.side; o.pm=4*o.side; cout<<"\n\n\t\tThe perimeter is "<<o.pm; getch(); break; } else if(o.cho==3) { cout<<"\n\n\t\tEnter the length of diagonals:"; cin>>o.d1>>o.d2; o.side=rh_side(o.d1,o.d2); cout<<"\n\n\t\tThe length of side is "<<o.side; getch(); break; } else goto repeat; case'8': for(o.a1=100,o.a2=160,o.a3=190,o.a4=70,o.b1=200,o.b2=200,o.b3=270,o.b4=270;o.a1<425,o.a2<525,o.a3<475,o.a4<380;o.a1++,o.a2++,o.a3++,o.a4++) { cleardevice(); line(o.a1,o.b1,o.a2,o.b2); line(o.a2,o.b2,o.a3,o.b3); line(o.a1,o.b1,o.a4,o.b4); line(o.a3,o.b3,o.a4,o.b4); delay(10); } settextstyle(6,0,5); outtextxy(130,30,"Trapezium"); cout<<"\n\n\n\n\n\n\t\t1)Area\t\t2)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.cho; if(o.cho==1) { cout<<"\n\n\t\tEnter the lengths of parallel sides \n\t\tand distance between them:"; cin>>o.d1>>o.d2>>o.h; o.area=trap_area(o.d1,o.d2,o.h); cout<<"\n\n\t\tThe area is "<<o.area; getch(); break; } else goto repeat; case'9':goto repeat; } break; case'3':clrscr(); cleardevice(); setbkcolor(5); settextstyle(6,0,4); outtextxy(120,30,"Welcome to 3-D figures"); cout<<"\n\n\n\n\n\n\n\t\t1)Cube\t\t2)Cubiod\n\n\t\t3)Cylinder\t4)Hollow cylinder\n\n\t\t5)Cone\t\t6)Sphere\n\n\t\t7)Hemisphere\t8)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.ch3; clrscr(); cleardevice(); switch(o.ch3) { case'1':for(o.a1=0,o.a2=100,o.a3=100,o.a4=0,o.b1=0,o.b2=0,o.b3=100,o.b4=100;o.a1<450,o.a2<550,o.a3<450,o.a4<550,o.b1<250,o.b2<250,o.b3<350,o.b4<350;o.a1+=2,o.a2+=2,o.a3+=2,o.a4+=2,o.b1++,o.b2++,o.b3++,o.b4++) { cleardevice(); line(o.a1,200,o.a2,200); line(o.a2,200,o.a3,300); line(o.a1,200,o.a4,300); line(o.a3,300,o.a4,300); delay(10); line(450,o.b1,550,o.b2); line(550,o.b2,550,o.b3); line(450,o.b1,450,o.b4); line(550,o.b3,450,o.b4); delay(11); } delay(190); line(o.a1,200,449,o.b1); delay(190); line(549,o.b2,o.a2,200); delay(190); line(449,o.b4,o.a4,300); delay(190); line(549,o.b3,o.a3,300); delay(190); settextstyle(6,0,5); outtextxy(130,30,"Cube"); cout<<"\n\n\n\n\n\n\t\t1)Volume\t\t2)Surface area\n\n\t\t3)Diagonal\t\t4)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.cu; if(o.cu==1) { cout<<"\n\n\t\tEnter side:"; cin>>o.side; o.vol=cu_vol(o.side,o.side,o.side); cout<<"\n\n\t\tThe volume is "<<o.vol; getch(); break; } else if(o.cu==2) { cout<<"\n\n\t\tEnter the length of side:"; cin>>o.side; o.area=cu_sa(o.side,o.side,o.side); cout<<"\n\n\t\tThe surface area is "<<o.area; getch(); break; } else if(o.cu==3) { cout<<"\n\n\t\tEnter the side:"; cin>>o.side; o.d=cu_diag(o.side,o.side,o.side); cout<<"\n\n\t\tThe diagonal is "<<o.d; getch(); break; } else if(o.cu==4) goto repeat; break;
Member • Nov 1, 2009
[COLOR=Red] case'2':for(o.a1=80,o.a2=210,o.a3=210,o.a4=80,o.b1=0,o.b2=0,o.b3=100,o.b4=100;o.a1<400,o.a2<550,o.a3<550,o.a4<400,o.b1<200,o.b2<200,o.b3<300,o.b4<300;o.a1+=3,o.a2+=3,o.a3+=3,o.a4+=3,o.b1+=2,o.b2+=2,o.b3+=2,o.b4+=2) { cleardevice(); line(o.a1,250,o.a2,250); line(o.a2,250,o.a3,350); line(o.a1,250,o.a4,350); line(o.a3,350,o.a4,350); delay(10); line(410,o.b1,540,o.b2); line(540,o.b2,540,o.b3); line(540,o.b3,410,o.b4); line(410,o.b1,410,o.b4); delay(15); } delay(190); line(376,250,410,o.b1); delay(190); line(540,o.b2,506,250); delay(190); line(410,o.b4,376,350); delay(190); line(540,o.b3,506,350); delay(190); settextstyle(6,0,5); outtextxy(130,30,"Cuboid"); cout<<"\n\n\n\n\n\n\t\t1)Volume\t\t2)Surface area\n\n\t\t3)Diagonal\t\t4)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.cu; if(o.cu==1) { cout<<"\n\n\t\tEnter the sides:"; cin>>o.a>>o.b>>o.c; o.vol=cu_vol(o.a,o.b,o.c); cout<<"\n\n\t\tThe volume is "<<o.vol; getch(); break; } else if(o.cu==2) { cout<<"\n\n\t\tEnter the sides:"; cin>>o.a>>o.b>>o.c; o.area=cu_sa(o.a,o.b,o.c); cout<<"\n\n\t\tThe surface area is "<<o.area; getch(); break; } else if(o.cu==3) { cout<<"\n\n\t\tEnter the sides:"; cin>>o.a>>o.b>>o.c; o.d=cu_diag(o.a,o.b,o.c); cout<<"\n\n\t\tThe diagonal is "<<o.d; getch(); break; } else if(o.cu==4) goto repeat; break; case'3':for(o.a1=200;o.a1<270;o.a1++) { cleardevice(); ellipse(550,200,1,361,30,15); ellipse(550,o.a1,1,361,30,15); line(520,200,520,o.a1); line(580,200,580,o.a1); delay(30); } line(520,200,520,o.a1); line(580,200,580,o.a1); settextstyle(6,0,5); outtextxy(130,30,"Cylinder"); cout<<"\n\n\n\n\n\n\t\t1)Volume\t\t\t2)Total surface area\n\n\t\t3)Curved surface area\t\t4)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.cyl; if(o.cyl==1) { cout<<"\n\n\t\tEnter the radius and height:"; cin>>o.rad>>o.h; o.vol=cyl_vol(o.rad,o.h); cout<<"\n\n\t\tThe volume is "<<o.vol; getch(); break; } else if(o.cyl==2) { cout<<"\n\n\t\tEnter the radius and height:"; cin>>o.rad>>o.h; o.area=cyl_sa(o.rad,o.h); cout<<"\n\n\t\tThe total surface area is "<<o.area; getch(); break; } else if(o.cyl==3) { cout<<"\n\n\t\tEnter the radius and height:"; cin>>o.rad>>o.h; o.area=cyl_csa(o.rad,o.h); cout<<"\n\n\t\tThe curved surface area is "<<o.area; getch(); break; } else if(o.cyl==4) goto repeat; break; case'4': for(o.a1=200;o.a1<310;o.a1++) { cleardevice(); ellipse(550,200,1,361,30,20); ellipse(550,o.a1,1,361,30,20); ellipse(550,200,1,361,45,35); ellipse(550,o.a1,1,361,45,35); line(520,200,520,o.a1); line(580,200,580,o.a1); line(505,200,505,o.a1); line(595,200,595,o.a1); delay(30); } line(520,200,520,o.a1); line(580,200,580,o.a1); line(505,200,505,o.a1); line(595,200,595,o.a1); settextstyle(6,0,5); outtextxy(130,30,"Hollow Cylinder"); cout<<"\n\n\n\n\n\n\t\t1)Volume\t\t\t2)Total surface area\n\n\t\t3)Curved surface area\t\t4)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.cyl; if(o.cyl==1) { cout<<"\n\n\t\tEnter the inner and outer radii and height:"; cin>>o.rad2>>o.rad1>>o.h; o.vol=ho_cyl_vol(o.rad2,o.rad1,o.h); cout<<"\n\n\t\tThe volume is "<<o.vol; getch(); break; } else if(o.cyl==2) { cout<<"\n\n\t\tEnter the inner and outer radii and height:"; cin>>o.rad2>>o.rad1>>o.h; o.area=ho_cyl_sa(o.rad1,o.rad2,o.h); cout<<"\n\n\t\tTne total surface area is "<<o.area; getch(); break; } else if(o.cyl==3) { cout<<"\n\n\t\tEnter the inner and outer radii and height:"; cin>>o.rad2>>o.rad1>>o.h; o.area=ho_cyl_csa(o.rad1,o.rad2,o.h); cout<<"\n\n\t\tThe curved surface area is "<<o.area; getch(); break; } else if(o.cyl==4) goto repeat; break; case'5': for(o.a1=10,o.b1=0;o.a1<40,o.b1<25;o.a1++,o.b1++) { cleardevice(); ellipse(550,350,1,361,o.a1,o.b1); delay(12); } delay(100); line(514,350,550,250); delay(100); line(550,250,586,350); delay(100); line(550,350,517,350); delay(100); line(550,350,550,250); delay(100); settextstyle(6,0,5); outtextxy(130,30,"Cone"); cout<<"\n\n\n\n\n\n\t\t1)Volume\t\t\t2)Total surface area\n\n\t\t3)Curved surface area\t\t4)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.con; if(o.con==1) { cout<<"\n\n\t\tEnter the radius and height:"; cin>>o.rad>>o.h; o.vol=con_vol(o.rad,o.h); cout<<"\n\n\t\tThe volume is "<<o.vol; getch(); break; } else if(o.con==2) { cout<<"\n\n\t\tEnter the radius and height:"; cin>>o.rad>>o.h; o.area=con_sa(o.rad,o.h); cout<<"\n\n\t\tThe total surface area is "<<o.area; getch(); break; } else if(o.con==3) { cout<<"\n\n\t\tEnter the radius and height:"; cin>>o.rad>>o.h; o.area=con_csa(o.rad,o.h); cout<<"\n\n\t\tThe curved surface area is "<<o.area; getch(); break; } else if(o.con==4) goto repeat; break; case'6': for(o.a1=0;o.a1<362;o.a1++) { ellipse(450,300,0,o.a1,79,79); ellipse(450,300,0,o.a1,79,20); delay(10); } delay(200); line(450,300,450,221); delay(200); line(450,300,371,300); settextstyle(6,0,5); outtextxy(130,30,"Sphere"); cout<<"\n\n\n\n\n\n\t\t1)Volume\n\n\t\t2)Total surface area\n\n\t\t3)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.sph; if(o.sph==1) { cout<<"\n\n\t\tEnter the radius:"; cin>>o.rad; o.vol=sph_vol(o.rad); cout<<"\n\n\t\tThe volume is "<<o.vol; getch(); break; } else if(o.sph==2) { cout<<"\n\n\t\tEnter the radius:"; cin>>o.rad; o.area=sph_sa(o.rad); cout<<"\n\n\t\tThe surface area is "<<o.area; getch(); break; } else if(o.sph==3) goto repeat; break; case'7': for(o.a2=180,o.a1=0;o.a1<362,o.a2<361;o.a1+=2,o.a2++) { cleardevice(); pieslice(450,300,180,o.a2,79); ellipse(450,300,180,o.a2,79,79); setcolor(14); setfillstyle(EMPTY_FILL,12); ellipse(450,300,0,o.a1,79,20); delay(10); } setcolor(5); line(450,300,529,300); delay(100); delay(1000); setcolor(14); line(450,300,450,379); delay(200); line(450,300,371,300); settextstyle(6,0,5); outtextxy(130,30,"Hemi Sphere"); cout<<"\n\n\n\n\n\n\t\t1)Volume\n\n\t\t2)Total surface area\n\n\t\t3)Curved surface area\n\n\t\t4)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.sph; if(o.sph==1) { cout<<"\n\n\t\tEnter the radius:"; cin>>o.rad; o.vol=sem_sph_vol(o.rad); cout<<"\n\n\t\tThe volume is "<<o.vol; getch(); break; } else if(o.sph==2) { cout<<"\n\n\t\tEnter the radius:"; cin>>o.rad; o.area=sem_sph_sa(o.rad); cout<<"\n\n\t\tThe total surface is "<<o.area; getch(); break; } else if(o.sph==3) { cout<<"\n\n\t\tEnter the radius:"; cin>>o.rad; o.area=sem_sph_csa(o.rad); cout<<"\n\n\t\tThe curved surface is "<<o.area; getch(); break; } else if(o.sph==4) goto repeat; break; case'8':goto repeat; } // end of switch(ch3) // break; case'4':clrscr(); cleardevice(); setbkcolor(5); settextstyle(6,0,4); outtextxy(120,30,"Trignometric and log functions"); cout<<"\n\n\n\n\n\n\n\t\t1)Sin\t\t\t\t2)Cos\n\n\t\t3)Tan\t\t\t\t4)Natural Log\n\n\t\t5)Log\t\t\t\t6)Square root\n\n\t\t7)Number to the power\t\t8)Absolute value\n\n\t\t9)Exit"; cout<<"\n\n\t\tEnter your choice:"; cin>>o.ch4; switch(o.ch4) { case'1':{ cout<<"\n\n\t\tEnter the angle:"; cin>>o.a; cout<<"\n\n\t\tThe sin is "<<sinh(o.a); getch(); break; } case'2':{ cout<<"\n\n\t\tEnter the angle:"; cin>>o.a; cout<<"\n\n\t\tThe cos is "<<cosh(o.a); getch(); break; } case'3':{ cout<<"\n\n\t\tEnter the angle:"; cin>>o.a; cout<<"\n\n\t\tThe tan is "<<tanh(o.a); getch(); break; } case'4':{ cout<<"\n\n\t\tEnter the number:"; cin>>o.a; cout<<"\n\n\t\tThe natural log is "<<log(o.a); getch(); break; } case'5':{ cout<<"\n\n\t\tEnter the number:"; cin>>o.a; cout<<"\n\n\t\tThe log to base 10 is "<<log10(o.a); getch(); break; } case'6':{ cout<<"\n\n\t\tEnter the number:"; cin>>o.a; cout<<"\n\n\t\tThe square root is "<<sqrt(o.a); getch(); break; } case'7':{ cout<<"\n\n\t\tEnter the number:"; cin>>o.a; cout<<"\n\n\t\tEnter the power:"; cin>>o.b; cout<<"\n\n\t\tThe result is "<<pow(o.a,o.b); getch(); break; } case'8':{ cout<<"\n\n\t\tEnter the number:"; cin>>o.lo; cout<<"\n\n\t\tThe absolute value is "<<abs(o.lo); getch(); break; } } case'9': goto repeat; } //end of master switch repeat: clrscr(); cleardevice(); cout<<"\n\n\n\t\tDo you want to continue?(y/n)"; cin>>o.ans; if(o.ans=='y') goto again; else clrscr(); cleardevice(); setbkcolor(12); setcolor(14); for(o.left=0,o.top=0,o.right=640,o.bottom=480,o.y0=0,o.l=0,o.color=0;o.left<149,o.right>501,o.top<149,o.bottom>356;o.left++,o.top++,o.right--,o.bottom--,o.y0+=2,o.l++,o.color++) { setcolor(o.color); rectangle(o.left,o.top,o.right,o.bottom); delay(40); settextstyle(4,0,4); outtextxy(151,147,"************************* "); outtextxy(151,300,"************************* "); settextstyle(10,0,4); outtextxy(170,210,"THANK YOU"); delay(8); } setcolor(14); settextstyle(4,0,4); outtextxy(151,147,"************************* "); outtextxy(151,300,"************************* "); settextstyle(10,0,4); outtextxy(170,210,"THANK YOU"); delay(6000); exit(0); getch(); } // function definations // float addi(int a,int b) { return (a+b); } float sub(int a,int b) { return (a-b); } float mult(int a,int b) { return (a*b); } float divi(int a,int b) { return (a/b); } float rem(int a ,int b) { return (a%b); } float disc(int a,int b,int c) { return (b*b -4*a*c); } float roots(int a,int b,int disc) { return ((-b+sqrt(disc))/2*a); } ///2d/// float area(int a,int b) { return (a*b); } float peri(int a, int b) { return (2*(a+b)); } float area(int a,int b,int c) { int s; s=(a+b+c)/2; return (sqrt(s*(s-a)*(s-b)*(s-c))); } float peri(int a,int b,int c) { return (a+b+c); } float diag(int a,int b) { return (sqrt(a*a+b*b)); } float c_a1(int a) { return (3.14*a*a); } float c_a2(int a) { return (3.14*a*a*(0.25)); } float tri_roc(int a,int b,int c,int d) { return ((a*b*c)*d/4); } float circum1(int a) { return (6.28*a); } float circum2(int a) { return (3.14*a); } float rh_side(int a,int b) { return (0.5*(sqrt(a*a+b*b))); } float trap_area(int a,int b,int c) { return ((a+b)*c/2); } float circ_sec(int a,int b) { return ((3.14*a*a*b)/360); } float circ_arc(int a,int b) { return ((3.14*2*a*b)/360); } //3d// //////////////////// float cu_vol(int a,int b,int c) { return (a*b*c); } float cu_sa(int a,int b,int c) { return (2*(a*b+b*c+c*a)); } float cu_diag(int a,int b,int c) { return (sqrt(a*a+b*b+c*c)); } float cyl_vol(int a,int b) { return (3.14*a*a*b); } float cyl_sa(int a,int b) { return ((2*3.14*a*a*b) + (2*3.14*a*a)); } float cyl_csa(int a,int b) { return (2*3.14*a*b); } float ho_cyl_vol(int a1,int a2,int b) { return (3.14*b*(a1*a1 - a2*a2)); } float ho_cyl_sa(int a1,int a2,int b) { return (2*3.14*(a1-a2)*(b+a1+a2)); } float ho_cyl_csa(int a1,int a2,int b) { return (2*3.14*b*(a1-a2)); } float con_vol(int a,int b) { return ((3.14*a*a*b)/3); } float con_sa(int a,int b) { return (3.14*a*(a+sqrt(a*a+b*b))); } float con_csa(int a,int b) { return (3.14*a*(sqrt(a*a+b*b))); } float sph_vol(int a) { return ((4*3.14*a*a*a)/3); } float sph_sa(int a) { return (4*3.14*a*a); } float sem_sph_vol(int a) { return ((2*3.14*a*a*a)/3); } float sem_sph_sa(int a) { return (3*3.14*a*a) ; } float sem_sph_csa(int a) { return (2*3.14*a*a); }[/COLOR]
Administrator • Nov 1, 2009
.. [ / code] tags.