C Program For Scientific Calculator: Mohammed Kaif 22K81A12G2
C Program For Scientific Calculator: Mohammed Kaif 22K81A12G2
Project Report On
BACHELOR OF TECHNOLOGY
in
INFORMATION TECHNOLOGY
by
Mr M.Manohar
ASSISTANT PROFESSOR
An autonomous Institute
NBA & NAC A+ Accredited
Dhulapally, Secunderbad-500100
Dhulapally, Secunderbad-500100
CERTIFICATE
This is to certify the project entitled C program for Scientific calculator is being submitted
is recorded of bonafide work carried out by them. The result embodied in thisreport have been
i
St. MARTIN’S ENGINEERING COLLEGE
An autonomous Institute
NBA & NAC A+ Accredited
Dhulapally, Secunderabad-500100
DECLARATION
hereby declare that the work presented in the Project Work entitled as (Title) is the outcome of
our own bonafide work and is correct to the best of our knowledge and this work has been
undertaken taking care of Engineering Ethics. This resultembodied in this project report has not
ii
ACKNOWLEDGEMENT
Our sincere thanks to Dr P. Santosh Kumar Patra, principal, St. Martin’s engineering
college, for giving this opportunity to carry out the present project work. We would like to take
this opportunity to express heartfelt gratitude for head of the department Dr. Ranadheer
Reddy, who provided us support and valuable inputs at various stages of this project work.
We would like to take this opportunity to express our sincere appreciation to all the people who
were helpful in making this project successful. First of all, we would like to express our
gratitude to our guide, Mrs. M.Manohar Assistant Professor, for her valuable comments,
guidance, and discussions that guided us well in the process of our project.
Finally, we express our sincere thanks to all teaching and non-teaching staff that guided and
helped us to complete the project work successfully.
iii
TABLE OF CONTENTS
TITLE PAGE NO
Acknowledgement iii
iv
Introduction
vi
Algorithm
vii
Flowchart
1
Source code
2
Expected output
3
4
5
6
iv
Introduction :
Introduction :
CREATING SCIENTIFIC CALCULATOR :
You have to need to creat scientific calculator class to perform task related to
scientific calculations. Which include finding square or cube etc.
The scientific calculator perform following task.
You have to need to creat scientific calculator class to perform task related to
scientific calculations. Which include finding square or cube etc.
The scientific calculator perform following task.
You have to need to creat scientific calculator class to perform task related to
scientific calculations. Which include finding square or cube etc.
The scientific calculator perform following task.
1. Determine the square of the number.
2. Determine the square root of the number
3. Determine the first number power of the second number
4. Determine the factorial of a number
5. Determine the sin, cos and tan value of the number.
6. Determine the logarithm, natural logarithm and exponential of the
number.
To perform the above mentioned task in scientific calculator implements the following
member function.
FUNCTION DESCRIPTION
Square accept a number and returns the square of the number
Squae root accept a number and returns the square root of number
v
Cube accept two number and returns the first power to 2nd num.
Fact returns a factorial of an input number.
Sin_fun returns the sin value of an input number.
Cos_fun return the cos value of an input number.
Tan_fun return the tan value of an input number
Log_fun return the log value of an input number
Log10_fun return the log10 value of an input number.
Exp_fun return the exp value of an input number.
FUNCTION DESCRIPTION
Square accept a number and returns the square of the number
Squae root accept a number and returns the square root of number
Cube accept two number and returns the first power to 2nd num.
Fact returns a factorial of an input number.
Sin_fun returns the sin value of an input number.
Cos_fun return the cos value of an input number.
Tan_fun return the tan value of an input number
Log_fun return the log value of an input number
Log10_fun return the log10 value of an input number.
Exp_fun return the exp value of an input number.
You have to need to creat scientific calculator class to perform task related to
scientific calculations. Which include finding square or cube etc.
The scientific calculator perform following task.
You have to need to creat scientific calculator class to perform task related to
scientific calculations. Which include finding square or cube etc.
The scientific calculator perform following task.
You have to need to creat scientific calculator class to perform task related to
vi
scientific calculations. Which include finding square or cube etc.
The scientific calculator perform following task.
You have to need to creat scientific calculator class to perform task related to
scientific calculations. Which include finding square or cube etc.
The scientific calculator perform following task.
Basically we all engineering students use a scientific calculator as our maths calculation
instrument
So what is a scientific calculator means ?
A scientific calculator is an electronic calculator, either desktop or handheld, designed to perform
mathematical operations. They have completely replaced slide rules and are used in both educational
and professional settings.
To know the process of the calculator working principle I choose the scientific calculator as my project work
We can make a simple calculator using C language by two approaches using switch case and if-else
statement. But to create a scientific calculator I used the switch case and break statement ;
vii
FLOWCHART :
viii
SOURCECODE:
#include<stdio.h>
#include<math.h>
int main(void) {
int choice, i, a, b;
float x, y, result;
do {
printf( "\n Select your operation (0 to exit):\n ");
printf("1. Addition\n 2. Subtraction\n 3. Multiplication\n 4. Division\n");
printf("5. Square root\n 6. X ^ Y\n 7. X ^ 2\n 8. X ^ 3\n");
printf("9. 1 / X\n 10. X ^ (1 / Y)\n 11. X ^ (1 / 3)\n");
printf("12. 10 ^ X\n 13. X!\n 14. %\n 15. log10(x)\n 16. Modulus\n");
printf("17. Sin(X)\n 18. Cos(X)\n 19. Tan(X)\n 20. Cosec(X)\n");
printf("21. Cot(X)\n 22. Sec(X)\n");
printf("Choice:");
scanf( "%d", &choice);
if(choice == 0) exit(0);
switch(choice) {
case 1:
printf("Enter X: ");
scanf( "%f", &x);
printf( "\nEnter Y: " );
scanf( "%f", &y);
result = x + y;
printf( "\n Result: %f", result);
break;
case 2:
printf("Enter X: ");
scanf("%f", &x);
printf( "\n Enter Y: ");
scanf("%f", &y);
result = x - y;
printf("\n Result: %f", result);
break;
case 3:
printf("Enter X: ");
scanf("%f", &x);
printf("\n Enter Y: ");
scanf("%f", &y);
result = x * y;
printf("\n Result: %f", result);
break;
case 4:
printf("Enter X: ");
scanf("%f", &x);
printf("\n Enter Y: ");
scanf("%f", &y);
result = x / y;
printf("\n Result: %f", result);
ix
break;
case 5:
printf("Enter X: ");
scanf("%f", &x);
result = sqrt(x);
printf("\n Result: %f", result);
break;
case 6:
printf("Enter X: ");
scanf("%f", &x);
printf("\n Enter Y: ");
scanf("%f", &y);
result = pow(x, y);
printf("\n Result: %f", result);
break;
case 7:
printf("Enter X: ");
scanf("%f", &x);
result = pow(x, 2);
printf(" \n Result: %f", result);
break;
case 8:
printf("Enter X: ");
scanf("%f", &x);
result = pow(x, 3);
printf("\n Result: %f", result);
break;
case 9:
printf("Enter X: ");
scanf("%f", &x);
result = pow(x, -1);
printf("\n Result: %f", result);
break;
case 10:
printf("Enter X: ");
scanf("%f", &x);
printf("\n Enter Y: ");
scanf("%f", &y);
result = pow(x, (1/y));
printf("\n Result: %", result);
break;
case 11:
printf("Enter X: ");
scanf("%f", &x);
y = 3;
result = pow(x, (1/y));
printf("\nResult: %f", result);
break;
case 12:
printf("Enter X: ");
scanf("%f", &x);
result = pow(10, x);
printf("\n Result: %f", result);
break;
case 13:
x
printf("Enter X: ");
scanf("%f", &x);
result = 1;
for(i = 1; i <= x; i++) {
result = result * i;
}
printf("\n Result: %.f", result);
break;
case 14:
printf("Enter X: ");
scanf("%f", &x);
printf("\n Enter Y: ");
scanf("%f", &y);
result = (x * y) / 100;
printf("\n Result: %.2f", result);
break;
case 15:
printf("Enter X: ");
scanf("%f", &x);
result = log10(x);
printf("\n Result: %.2f", result);
break;
case 16:
printf("Enter X: ");
scanf("%d", &a);
printf("\n Enter Y: ");
scanf("%d", &b);
result = a % b;
printf(" \n Result: %d", result);
break;
case 17:
printf("Enter X: ");
scanf( "%f", &x);
result = sin(x * 3.14159 / 180);
printf( " \n Result: %.2f", result);
break;
case 18:
printf("Enter X:");
scanf( "%f", &x);
result = cos(x * 3.14159 / 180);
printf(" \n Result: %.2f", result);
break;
case 19:
printf("Enter X: ");
scanf( "%f", &x);
result = tan(x * 3.14159 / 180);
printf(" \n Result: %.2f", result);
break;
case 20:
printf("Enter X:");
scanf("%f", &x);
result = 1 / (sin(x * 3.14159 / 180));
printf(" \n Result: %.2f", result);
break;
case 21:
xi
printf("Enter X:");
scanf("%f", &x);
result = 1 / tan(x * 3.14159 / 180);
printf( " \n Result: %.2f", result);
break;
case 22:
printf("Enter X: ");
scanf( "%f", &x);
result = 1 / cos(x * 3.14159 / 180);
printf( " \n Result: %.2f", result);
break;
default:
printf( " \n Invalid Choice! ");
}
} while(choice);
return
0;
xii
OUTPUT: