Sie sind auf Seite 1von 5

//PROJECT ON:- Scientific Calculator

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>
#include<graphics.h>

// defining functions
void clog()
{
double a,r;
printf("\n Enter the number : ");
scanf("%lf",&a);
r=log10(a);
printf("\n The common logrithm of %.0lf is : %.4lf",a,r);
}
void nlog()
{
double a,r;
printf("\n Enter the number : ");
scanf("%lf",&a);
r=log(a);
printf("\n The natural logrithm of %.0lf is : %.4lf",a,r);
}
void sq()
{
double a,r;
printf("\n Enter the number : ");
scanf("%lf",&a);
r=a * a;
printf("\n The square of %.0lf is : %.2lf",a,r);
}
void sqroot()
{
double a,r;
printf("\n Enter the number : ");
scanf("%lf",&a);
r=sqrt(a);
printf("\n The square root of %.0lf is : %.2lf",a,r);
}
void sine()
{
double a,r;
printf("\n Enter the number : ");
scanf("%lf",&a);
r=sin(a*3.14/180);
printf("\n The sine of %.0lf is : %.4lf",a,r);

}
void cosine()
{
double a,r;
printf("\n Enter the number : ");
scanf("%lf",&a);
r=cos(a*3.14/180);
printf("\n The cosine of %.0lf is : %.4lf",a,r);
}
void tann()
{
double a,r;
printf("\n Enter the number : ");
scanf("%lf",&a);
r=tan(a*3.14/180);
printf("\n The tan of %.0lf is : %.4lf",a,r);
}
void add()
{
double a,b,r;
printf("\n Enter the FIRST number : ");
scanf("%lf",&a);
printf("\n Enter the SECOND number : ");
scanf("%lf",&b);
r=a+b;
printf("\n The result of Addition is :%.2lf ",r);
}
void sub()
{
double a,b,r;
printf("\n Enter the FIRST number : ");
scanf("%lf",&a);
printf("\n Enter the SECOND number : ");
scanf("%lf",&b);
r=a-b;
printf("\n The result of Subraction is :%.2lf ",r);
}
void mul()
{
double a,b,r;
printf("\n Enter the FIRST number : ");
scanf("%lf",&a);
printf("\n Enter the SECOND number : ");
scanf("%lf",&b);
r=a*b;
printf("\n The result of Multiplication is : %.2lf",r);
}
void div()
{

double a,b,r;
printf("\n Enter the FIRST number : ");
scanf("%lf",&a);
printf("\n Enter the SECOND number : ");
scanf("%lf",&b);
r=a/b;
printf("\n The result of Division is : %.2lf ",r);
}

/* main function*/
void main()
{
int c1,c2,n,i;
double x,y,z;
clrscr();
textmode(C80);
hai:
clrscr();
gotoxy(30,4);
printf(" WELCOME !!! ");
printf("\n\n\n\t\t *** Main menu ***\n\n\t---------------------------------------------");
printf("\n\t Press :-");
printf("\n\t 1 -> To Perform Calculations On 1 Number ");
printf("\n\t 2 -> To Perform Calculations On 2 Numbers ");
printf("\n\t 3 -> To Quit \n\t----------------------------------------------");
printf("\n\n Enter your choice : ");
scanf("%d",&n);
if(n==1)
{
clrscr();
hai1:
printf("\n The Choices are :-\n ------------------ ");
printf("\n\t 1.Common Logrithm\n\t 2.Natural Logrithm\n\t 3.Square\n\t 4.Square Root\n\t
5.Sine\n\t 6.Cosine\n\t 7.Tan ");
printf("\n\n Enter your choice : ");
scanf("%d",&c1);
switch(c1)
{
case 1:
clog();
break;
case 2:
nlog();
break;
case 3:
sq();
break;
case 4:
sqroot();
break;
case 5:
sine();
break;
case 6:

cosine();
break;
case 7:
tann();
break;
default:
clrscr();
goto hai1;
}
}
if(n==2)
{
clrscr();
hai2:
printf("\n The Choices are :-\n ------------------");
printf("\n\t 1.Addition\n\t 2.Subraction\n\t 3.Multiplication\n\t 4.Division ");
printf("\n\n Enter Your Choice: ");
scanf("%d",&c2);
switch(c2)
{
case 1:
add();
break;
case 2:
sub();
break;
case 3:
mul();
break;
case 4:
div();
break;
default:
clrscr();
goto hai2;
}
}
if(n==3)
{
goto bye;
}
if((n!=1)&&(n!=2)&&(n!=3))
{
goto hai;
}
printf("\n\n\n press any key to continue....");
getch();
goto hai;
bye:
textcolor(YELLOW);
clrscr();
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");

printf("\n\t-----------------------------------------------------------------");
printf("\n\t\t\t\tTHANK YOU!!!");
printf("\n\t-----------------------------------------------------------------");
printf("\n\n\n\n\t\tby :-\n\t\t---");
printf("\n\t\t\t***************************");
printf("\n\t\t\t*
*");
printf("\n\t\t\t* G.PALANIKUMAR (273015) *");
printf("\n\t\t\t* A.SAKTHISUNDAR (273023) *");
printf("\n\t\t\t*
EIE -II YEAR
*");
printf("\n\t\t\t*
KCET
*");
printf("\n\t\t\t*
*");
printf("\n\t\t\t***************************");
getch();
for(i=0;i<25;i++)
{
printf("\n");
delay(250);
}
restorecrtmode();
}

Das könnte Ihnen auch gefallen