0% found this document useful (0 votes)
111 views10 pages

14 Me 98

This C program provides a menu-driven calculator with multiple mathematical functions. It begins by prompting the user to log in with a username and password. The main menu then displays options for arithmetic operations, matrix addition/subtraction, transpose, multiplication, quadratic equations, trigonometric ratios, power/square root, and remainder. Based on the user's selection, the appropriate function is called to perform the calculation and output the result before returning to the main menu.

Uploaded by

mueed6074
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views10 pages

14 Me 98

This C program provides a menu-driven calculator with multiple mathematical functions. It begins by prompting the user to log in with a username and password. The main menu then displays options for arithmetic operations, matrix addition/subtraction, transpose, multiplication, quadratic equations, trigonometric ratios, power/square root, and remainder. Based on the user's selection, the appropriate function is called to perform the calculation and output the result before returning to the main menu.

Uploaded by

mueed6074
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

#include<stdio.

h>
#include<conio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
void pass();
void menu();
void arithmatic();
void transpose();
void multiply();
void addsub();
void Quadratic();
void ratio();
void power();
void remainder();
void main()
{
{
pass();
}

n:
system("cls");
{
r1:
menu();
}
int a;
scanf("%d",&a);
if (a==1)
{
x9:
arithmatic();
printf("\nPress 1 to go back in main menu and Press 2 to repeat same program:");
int a11;
scanf("%d", & a11);
if(a11==1)
{
goto r1;
}
else if (a11==2)
{
goto x9;
}
}
else if(a==3)
{x10:
transpose();
printf("\nPress 1 to go back in main menue and Press 2 to repeat same program:");
int a11;
scanf("%d", & a11);
if(a11==1)
{
goto r1;

}
else if (a11==2)
{
goto x10;
}

}
else if (a==4)
{
h1:
multiply();
printf("\nPress 1 to go back in main menue and Press 2 to repeat same program:");
int a11;
scanf("%d", & a11);
if(a11==1)
{
goto r1;
}
else if (a11==2)
{
goto h1;
}
}
else if (a==2)
{
h2:
addsub();
printf("\nPress 1 to go back in main menue and Press 2 to repeat same program:");
int a11;
scanf("%d", & a11);
if(a11==1)
{
goto r1;
}
else if (a11==2)
{
goto h2;
}
}
else if (a==5)
{
h3:

Quadratic();
printf("\nPress 1 to go back in main menue and Press 2 to repeat same program:");
int a11;
scanf("%d", & a11);
if(a11==1)
{
goto r1;
}
else if (a11==2)
{
goto h3;
}

}
else if (a==6)
{

h7:
ratio();
printf("\nPress 1 to go back in main menue and Press 2 to repeat same program:");
int a11;
scanf("%d", & a11);
if(a11==1)
{
goto r1;
}
else if (a11==2)
{
goto h7;
}

}
else if(a==7)
{

h13:
power();
printf("\nPress 1 to go back in main menue and Press 2 to repeat same program:");
int a11;
scanf("%d", & a11);
if(a11==1)
{
goto r1;
}
else if (a11==2)
{
goto h13;
}
}
else if(a==8)
{
h26:
remainder();
printf("\nPress 1 to go ack in main menu and Press 2 to repeat same program:");
int a11;
scanf("%d", & a11);
if(a11==1)
{
goto r1;
}
else if (a11==2)
{
goto h26;
}
}
else
{ printf("You Pressed Wrong No.\nPlease press the correct Entry");

goto n;

getch();
}
void pass()
{ n:
char pwrd[]="uet";
char temp1[25] , temp2[25] , uname[]="uet" , ch;
int i=0;

//clrscr();
printf("Enter the username: ");
gets(temp1);
printf("Enter the password:");
while(1)
{
ch=getch();
// 1
if(ch==13)
// 2
break;
printf("*");
// 3
temp2[i++]=ch;
//4
}
temp2[i]='\0';
//5
if(!strcmp(uname,temp1)&&!strcmp(temp2,pwrd))
r:
//6
printf("\n\tWelcome to the CALCULATOR");
else
{ system("cls");
printf("\a\nPlease enter the correct username and password\n");
goto n;}
}
void menu()
{
{ printf(" \n\t\tHERE IT COMES !!!\n
THE WORLD'S BEST CALCULATOR!!\nSUBMITTED BY
:SYED MUEED ALI\nROLL NO. 14-ME-98\nSUBMITTED TO: SIR RIZWAN SAEED\n");}
{printf("For +,-,Mul,Divide:-\t \t\t Press 1\nFor addition and subtraction of matrices:- Press 2\nFor
Transpose of a matrix:-\t\t Press 3\nFor Multiplication of Matrices:-\t\t\b Press 4\n");}
{printf("For solving Quadratic Equations:-\t Press 5\nFor solving trigonometric functions:-\t
Press 6\nFor Power & Square Root function :-\t Press 7\n");}
{printf("For calculating Remainder:-\t\t Press 8\n");}
}
void arithmatic()

{
system("cls");
int lo;
int n;
int first, second, add, subtract, multiply;
float divide;
printf("Enter two integers\n");
scanf("%d%d", &first, &second);
printf("For Addition :-\t\t Press 1\nFor Subtraction :- \t\b Press 2\nFor Multiplication :-\t\b\b
Press 3\nFor Division :-\t\t Press 4\n");
scanf("%d",&lo);
add
= first + second;
subtract = first - second;
multiply = first * second;
divide
= first / (float)second;
if (lo==1)
{
printf("Sum = %d\n",add);

}
else if (lo==2)
{
printf("Difference = %d\n",subtract);
}
else if (lo==3)
{
printf("Multiplication = %d\n",multiply);
}
else if (lo==4)
{
printf("Division = %.2f\n",divide);
}

}
void transpose()
{

system("cls");
int g;

int i, j, k,m,n;
int s=0;
int a[200][200], b[200][200], p[200][200];
printf("Enter no of rows and column of matrix\n");
printf("Rows:");
scanf(" %d",&m);
printf("Columns:");
scanf("%d",&n);
printf("Enter the elements of matrix\n");
for ( i = 0 ; i < m ; i++ )
for ( j = 0 ; j < n ; j++ )
scanf("%d", &a[i][j]);
printf("Original matrix is:\n");
for ( i = 0 ; i < m ; i++ )
{
for ( j = 0 ; j < n ; j++ )
{
printf("%d\t", a[i][j]);
}
printf("\n");
}
printf("Transpose of a matrix is\n");
for (i=0;i<m;i++)
{
for (j=0;j<n;j++)
{
printf("%d\t",a[j][i]);
}
printf("\n");
}

}
void multiply()
{
system("cls");
int g;
int i, j, k,m,n;
int s=0;
int a[200][200], b[200][200], p[200][200];
printf("Enter no of rows and column of 1st matrix\n");
scanf("%d",&m);
scanf("%d",&n);
printf("Enter no of rows and columns of 2nd matrix\n");
scanf("%d",&m);
scanf("%d",&n);
printf("Enter the elements of first matrix\n");
for ( i = 0 ; i < m ; i++ )
for ( j = 0 ; j < n ; j++ )
scanf("%d", &a[i][j]);
printf("Enter the elements of second matrix\n");
for ( i = 0 ; i < m ; i++ )
for ( j = 0 ; j < n ; j++ )
scanf("%d", &b[i][j]);
for ( i = 0 ; i < m ; i++ )
{
for ( j = 0 ; j < n ; j++ )
{
for ( k = 0 ; k < m ; k++ )
{
s = s + a[i][k]*b[k][j];
}
p[i][j] = s;
s = 0;
}
}
printf("Product of entered matrices:-\n");
for ( i = 0 ; i < m ; i++ )
{
for ( j = 0 ; j < n ; j++ )
printf("%d\t", p[i][j]);
printf("\n");
}
}
void addsub()
{

system("cls");
int n;

int a1[3][3],a2[3][3],a3[3][3];
int i, j,k;
printf(" *Enter 3X3 Matrices*\n");
printf("Enter values for first matrix:\n");
for(i=0;i<=2;i=i+1)

for(j=0;j<=2;j=j+1)
{
scanf("%d",&a1[i][j]);
}
}
printf("\nEnter the values for second matrix:\n");
for(i=0;i<=2;i=i+1)
{
for(j=0;j<=2;j=j+1)
{
scanf("%d",&a2[i][j]);
}
}
printf("For Addition:- Press 1\nFor Subtraction:-Press 2\n");
scanf("%d",&k);
if (k==1)
{
printf("find the sum of two matrices\n");
for(i=0;i<=2;i=i+1)
{
for(j=0;j<=2;j=j+1)
{
a3[i][j]=a1[i][j]+a2[i][j];
}
}
for(i=0;i<=2;i=i+1)
{
for(j=0;j<=2;j=j+1)
{
printf("%d\t",a3[i][j]);
}
printf("\n");
}
}
else if(k==2)
{
printf("\nfind the difference of two matrices\n");
for(i=0;i<=2;i=i+1)
{
for(j=0;j<=2;j=j+1)
{
a3[i][j]=a1[i][j]-a2[i][j];
}
}
for(i=0;i<=2;i=i+1)
{
for(j=0;j<=2;j=j+1)
{
printf("%d\t",a3[i][j]);
}
printf("\n");
}

}
}
void Quadratic()
{
system("cls");
int n;
float a1,a2,a3;
char b1,b2,b3,b4,b5,b6,b7,b8;
float x1,x2;
printf("Enter your equatio in this formate \n a*x*x+b*x+c\n");
scanf("%f %c %c %c %c %c %f %c %c %c %f",
&a1,&b1,&b2,&b3,&b4,&b5,&a2,&b6,&b7,&b8,&a3);
if(a1==0)
{
printf("Invalid Equation");
}
else
{
x1=(((-1)*(a2))+ sqrt((a2*a2)-(4*a1*a3)))/(2*a1);
x2=(((-1)*(a2))- sqrt((a2*a2)-(4*a1*a3)))/(2*a1);
printf("%c=%f and %c=%f",b2,x1,b2,x2);
}
}
void ratio()
{
system("cls");
int n;
printf("Press 1.sin 2.cos 3.tan 4.sec 5.cosec 6.cot 7.sinh 8.cosh 9.tanh 10.cosech 11.sech
12.coth\n");
int a1;
scanf("%d",&a1);
printf("Enter your value of Angle in Degrees:-");
int a;
scanf("%d",&a);
switch (a1)
{
case 1:
printf("=%f", sin(a*3.147/180));
break;
case 2:
printf("=%f", cos(a*3.147/180));
break;
case 3:
printf("=%f", tan(a*3.147/180));
break;
case 4:
printf("=%f", 1/sin(a*3.147/180));
break;
case 5:
printf("=%f", 1/cos(a*3.147/180));
break;
case 6:
printf("=%f", 1/tan(a*3.147/180));

case 7:

break;
printf("=%f", sinh(a*3.147/180));
break;

case 8:
case 9:

printf("=%f", cosh(a*3.147/180));
break;
printf("=%f", tanh(a*3.147/180));
break;

case 10:
case 11:

printf("=%f", 1/sinh(a*3.147/180));
break;
printf("=%f", 1/cosh(a*3.147/180));
break;

case 12:

printf("=%f", tanh(a*3.147/180));
break;
default:
printf("Invalid Operation");
break;

}
}
void power()
{
system("cls");
int n;
printf("For Power:- Press 1\nSuqare Root:-Press 2\n");
int a;
scanf("%d",&a);
if(a==1)
{
int c;
float b;
printf("Enter your numbers for Power function\n");
scanf("%f %d",&b,&c);
printf("Power of Number is:");
printf("=%f",pow(b,c));
}
else if(a==2)
{
float b;
printf("Enter your number for Square Root Function:");
scanf("%f", &b);
printf("\nSquare Root of a number is:");
printf("%f", sqrt(b));
}
else
{
printf("Invalid Operation");
}
}
void remainder()
{

system("cls");
int a,b,c;
int n;
printf("Enter No. whose remainder is to calculate:");
scanf("%d",&a);
printf("Enter the Devisor:");
scanf("%d",&b);
c=a%b;
printf("Your reminder = %d",c);
}

You might also like