Professional Documents
Culture Documents
h>
#include<conio.h>
#include<math.h>
#include<Windows.h>
void menu();
void arithematic();
void trignometric();
void quardratic();
void threevariables();
void linearequation();
void matrix();
void main()
{int r=0;
do{char
ch=65,a[8]={0,0,0,0,0,0,0,0},password[8]={'m','u','n','e','e','b',0,0};
int i=0;
}while(r==0);
menu();
void menu()
{int choice=0;
char ch;
do{system("cls");
printf("\nCHOICE THE FUNCTION TO BE PERFORMED\n");
printf("\n1.Arithematic");
printf("\n2.trignometric Funtions\n3.Quadratic Equation Solver\n4.Equation of
three unknowns\n5.linear equation for three variables\n");
printf("6.Matrix\n");
scanf("%d",&choice);
switch(choice)
{case 1:
{arithematic();
break;}
case 2:
{trignometric();
break;}
case 3:
{quardratic();
break;}
case 4:
{threevariables();
break;}
case 5:
{linearequation();
break;}
case 6:
{
matrix();
break;}
default:
printf("\nWRONG ENTERY\n");
break;
}
printf("\nTo run the menu again\n enterY\n");
ch=getch();}
while(ch=='y'||ch=='Y');
}
void arithematic()
{
int a,b;
char c;
printf("\nEnter the expression for the arithematic calculations\n");
scanf("%d %c %d",&a,&c,&b);
switch(c)
{case '+':
{ printf("%d",a+b);
break;}
case '-':
{ printf("%d",a-b);
break;}
case '/':
{if(b!=0)
printf("%d",a/b);
else
break;}
case '%':
{ if(b!=0)
printf("%d",a%b);
else
break;}
case '*':
{ printf("%d",a*b);
break;}
default:
{ printf("\nINVALID ENTERY\n");
break;}
}}
void trignometric()
{int ch;
float radian,angle;
printf("\nENTER THE VALUE IN DEGREES\n");
scanf("%f",&angle);
radian=angle*3.14159/180;
printf("Enter (1) for sine\nenter (2) for cosine\n enter (3) for tan\n");
ch=getch();
switch(ch)
{case 49:
{printf("%f",sin(radian));
break;
}
case 50:
{printf("%f",cos(radian));
break;
}
case 51:
{printf("%f",tan(radian));
break;}
default:
printf("\nWRONG ENTERY\N");
}}
void quardratic()
{
float a,b,c,determinent,r1,r2,real,imag;
printf("Enter co efficients a b and c:");
scanf("%f%f%f",&a,&b,&c);
determinent=b*b-4*a*c;
if(determinent>0)
{
r1=(-b+sqrt(determinent))/(2*a);
r2=(-b-sqrt(determinent))/(2*a);
printf("Roots are :%f and %f",r1,r2);}
else if(determinent==0)
{r1=r2=-b/(2*a);
printf("Roots are :%f %f" ,r1,r2);}
else {real=-b/(2*a);
imag=sqrt(-determinent)/(2*a);
printf("The roots of the equation are: %f+%fi %f-%fi",real,imag,real,imag);}
}
void matrix()
{int m;
}
void threevariables()
{float a,b,c,d,l,m,n,k,p,D,q,r,s,x,y,z;
printf("\nPROGRAM TO SOLVE THREE VARIABLE LINEAR SIMULTANEOUS EQUATION\n");
D = (a*m*r+b*p*n+c*l*q)-(a*n*q+b*l*r+c*m*p);
x = ((b*r*k+c*m*s+d*n*q)-(b*n*s+c*q*k+d*m*r))/D;
y = ((a*n*s+c*p*k+d*l*r)-(a*r*k+c*l*s+d*n*p))/D;
z = ((a*q*k+b*l*s+d*m*p)-(a*m*s+b*p*k+d*l*q))/D;
void linearequation()
{int num=0,t,v=0,c=0,pt=0,m,p[10],pwr[10];
float a[10]={0,0,0},var[10],sol[10];
char ch=0,sign[10],variable[10]={0,0,0,0,0,0,0,0,0,0};
printf("Enter a linear eq such as 2x+3m+9d\n");
do{
scanf("%c",&ch);
if(ch==46)
pt=1;
else if(ch>=48&&ch<=57)
{ t=ch-48;
a[num]=10*a[num]+t;
if(pt>0)
pt++;}
else if(ch=='+'||ch=='-')
{sign[num]=ch;
if(pt>0)
{pt=pt-1;
m=pow(10.0,pt);
a[num]=a[num]/m;}
num++;
pt=0;}
else if(ch=='^'||p[num]==1)
{p[num]==1;
if(ch!='^')
{t=ch-48;
pwr[num]=10*pwr[num]+t;}}
else if(ch>=65&&ch<=90||ch>=97&&ch<=122)
variable[num]=ch;
else if(ch==10)
{if(pt>0)
{pt=pt-1;
m=pow(10.0,pt);
a[num]=a[num]/m;}
pt=0;
break;}
}
while(ch!=13);
for(int i=0;i<=num;i++)
{if(variable[i]!=0)
{printf("Enter the value of %c",variable[i]);
scanf("%f",&var[i]);}}
for(int j=0;j<=num;j++)
{if(a[j]==0)
sol[j]=var[j];
else if(variable[j]==0)
sol[j]=a[j];
else
sol[j]=a[j]*var[j];
}
for(int k=0;k<=num;k++)
switch(sign[k])
{case'+':
{sol[k+1]=sol[k]+sol[k+1];
c=k;
break;}
case'-':
{sol[k+1]=sol[k]-sol[k+1];
c=k;
break;}
}
printf("%f",sol[c+1]);