Sie sind auf Seite 1von 17

CSE-151 TERM PAPER

TOPIC: CALCULATOR

SUBMITTED TO: Mr. ROHITT SHARMA (Dept. Of CSE)

SUBMITTED BY: AJAY KUMAR Roll No.: 27 Section: K2005 Regd. No.: 11009446

ACKNOWLEDGEMENT

I would like to express my gratitude to all those who have helped me in the successful completion of my project. I want to thank the Department of CSE of Lovely Professional University for giving me permission to commence on this project. I would like to thank MR. ANAND KUMAR for helping me somehow and encouraged me to go ahead with my project. Especially, I would like to give my special thanks to my mother whose patient love enabled me to complete this work.

TABLE OF CONTENTS

1.INTRODUCTION 2.INTRODUCTION OF PROJECT 3. PROPOSED SYSTEM (i) DESCRIPTION (ii) SYSTEM REQUIREMENTS 3. REQUIREMENTS ANALYSIS 4. USING FUNCTIONS 5. SOURCE CODE 6. FUTURE SCOPE OF PROJECT 7. BIBLIOGRAPHY

Introduction:
C is a programming language developed at AT & Ts Bell Laboratories of USA in 1972. It was designed and written by a man named Dannis Ritchie. In the late seventies C began to replace the more familiar language of that time like PL/I, ALGOL, etc. No one pushed C. It was not made the official Bell Labs language. Thus, without any advertisement, Cs reputation spread and its pool of users grew. Ritchie seems to have been rather surprised that so many programmers preferred C to older language like FORTRAN or PL/I, or the newer ones like Pascal and APL. But, thats what happened. Possibly why C seems so popular is because it is reliable, simple and easy to use. Moreover, in an industry where newer languages, tools and technologies emerge and vanish day in and day out, a language that survived for more than three decades has to be really good. An opinion that is often heard today is - C has been already superceded by language like C++, C# and Java, so why bother to learn C today. I seriously bag to differ with this opinion. There are several reasons for this: (a) I believe that nobody can learn C++ or Java directly. This is because while learning these languages you have things like classes, objects, inheritance, polymorphism, templates, exception handling, references, etc. do deal with apart from knowing the actual language elements. Learning these complicated concepts when you are not even comfortable with the basic language elements is like putting the cart before the horse. Hence one should first

learn all the language elements very thoroughly using C language before migrating to C++, C# or Java. Though this two step learning process may take more time, but at the end of it you will definitely find it worth the trouble. (b) C++, C# or Java make use of a principle called Object Oriented Programming (OOP) to organize the program. This organizing principle has lots of advantage to offer. But even while using this organizing principle you would still need a good hold over the language elements of C and the basic programming skills.

(c) Though many C++ and Java based programming tools frameworks have evolved over the years the importance of C is still unchallenged because knowingly or unknowingly while using these frameworks and tools you would be still required to use core C language elements- another good reason why one should learn C before C++, C# or Java. (d) Major parts of popular operating system like windows UNIX, Linux are still written in C. This is because even today when it comes to performance (speed of execution) nothing beats C. Moreover, if one is to extend the operating system to work with new devices one needs to write device driver programs. These programs are exclusively written in C. (e) Mobile device like cellular phones and palmtops have become rage of today. Also, common consumer device like microwave ovens, washing machines and digital cameras getting smatter by the day. This smartness comes from the microprocessors, an operating system and program embedded in these devices. These programs not only have to run fast but also have to work in limited amount of memory. No wonder that such programs are written in C. With these constrains on time and space c is language of choice while building such operating systems and programs.

(f) You must have seen several professional 3D computer games where the user navigates some objects, like say a spaceships and fires bullets at the invaders. The essence of all such games is speed. Needless to say, such games wont become popular if they takes a long time to spaceship or to fire a bullet. To match expectation of the player the game has to react fast to the user input. This is where C language scores over other languages. many popular gaming frameworks have been built using C language. (g) At times one is required to very closely interact with the hardware devices. Since C provides several language elements that makes this interaction feasible without compromising the performance it is the preferred choice of the programmer.

Introduction of project:
The topic of my project is CLCULATOR. This program has main focus on scientific calculation. It makes calculation very easier. It will definitely help to solve the calculation. My project is very different to the older version in such a way that it is more users friendly and stores records than usual. All and over it is compact and easy to use.

PROPOSED SYSTEM

DESCRIPTION:

My software deals with calculator. I have used various decision statements like switch, if and else and various functions. C language really proved to be very helpful in building of my software as it is very user friendly and is structured language. It allows the programmer to work in small modules called functions. Thus my software will help in reducing the various scientific calculation.

SYSTEM REQUIREMENTS:

OPERATING SYSTEM: WINDOWS XP OR WINDOW VISTA VERSION OF C: TURBO C++ (VERSION 4.5) PROCESSOR: PENTIUM 4 @ 2.00 GHz OR HIGHER MEMORY (RAM): 128 MB OR HIGHER SYSTEM TYPE: 32 BIT OPERATING SYSTEM

REQUIREMENT ANALYSIS:
My system model is Lenovo Vista PC. The processor is Intel core 2 duo. With Intel Core 2 Duo desktop processor, the PC experiences a revolutionary performance, unbelievable system responsiveness, and energy-efficiency second to none. It gives Up to 6MB L2 cache Up to 1333 MHz front side bus The RAM memory of my computer is 2 GB. Here goes the function of RAM:

All of the data is held on the Hard Disk Drive - even Windows is stored there. When the computer is running, whenever it needs to open a program, file, or run a process that it hasn't in a while, it accesses the Hard Drive and runs the process that it's looking for through the processor. While it is processing, it may need to store and access numbers. These numbers are stored in the RAM (Random Access Memory). It completes processes by doing this routine over and over until the computer is turned off. RAM does not hold any amount of data that we can access - only the machine can. The breakdown of RAM is: 1 Gigabyte = 1024 Megabyte 1 Megabyte = 1024 Kilobytes 1 Kilobyte = 1024 Bytes 1 Byte = 8 bits 1 bit = 1 binary number (a 1 or a 0) So, 2 Gigs of ram holds appx. 8.60 x 10^9 bits. My PC works as a 32-BIT operating system. A 32-bit operating system is A binary digit, or bit, is the smallest unit of data that a computer can process. All other things being equal, the more bits your computer can process at the same time, the faster it is.

Most desktop computers manipulate bits in groups of 16 or 32. If you have two computers whose clock (processing) speed is identical, and one processes 32 bits at a time while the other processes 16, the 32bit

computer will be about twice as fast.

USING FUNCTION
In my software program used following types of functions:1. PRINTF function: - This function used for display the given data by the user through the keyboard. 2. SCANF function:- This function used for input the data by the user. 3. IF & ELSE statement:- This function used for check the condition where the condition is true, executed the body of

true block and if the true condition is false else body will be executed. 4. SWITCH statement:- It is used for generally for menu driven program, while using this function user directly go to the case where the user want to go, respected body will be executed. 5. BREAK statement:- It is used for getting out from the switch case. 1.1. Header files Ex. <stdio.h>,<conio.h> etc. 1.2. Switch case Ex. Case1,case2. 1.3. 1.4 Break Function Ex. Void. 1.5 Control statement Ex. And, or,not etc. 1.6 logical statement Ex. If,ifelse,nestedif etc.

SOURCE CODE
#include<stdio.h> #include<conio.h>

#include<iostream.h> #include<math.h> #include<process.h> #include<stdlib.h> void main() { clrscr(); int i; printf("**** WELCOME TO THE CALCULATION WORLD ****"); printf(" \n****NOW CHOOSE ONE OF THE FOLLOWING OPTIONS ****"); printf("\n {1} ADDDITION "); printf("\n {2} SUBTRACTION "); printf("\n {3} MULTIPLICATION "); printf("\n {4} DIVIDE "); printf("\n {5} POWER "); printf("\n {6} SQUAREROOT"); printf("\n {7} INVERSE"); printf("\n {8} FACTORIAL"); printf(\n {9} EXIT ); printf("\n PLEASE ENTER THE VALUE \n"); printf(" "); scanf(" %d",&i); switch(i) { case 1: int a,b,z,sum=0; printf("\n ENTER FIRST NUMBER "); scanf("%d",&a); printf("\n ENTER SECOND NUMBER "); scanf("%d",&b); z=a+b; sum=z; printf("\nSUM IS %d",sum); break; case 2: int c,d,subtraction=0; printf("\n ENTER FIRST NUMBER "); scanf("%d",&c); printf("\n ENTER SECOND NUMBER "); scanf("%d",&d); if(c>d) { subtraction=c-d; printf("SUBTRACTION IS =%d",subtraction);

} else { subtraction=d-c; printf("SUBTRACTION IS -%d",subtraction); } break; case 3: int e,f,multiplication=0; printf("ENTER THE FIRST NUMBER "); scanf("%d",&e); printf("\nENTER SECOND NUMBER "); scanf("%d",&f); multiplication=e*f; printf("MULTIPLICATION IS =%d",multiplication); break; case 4: int g,h,remainder=0,quotient=0; printf("ENTER THE FIRST NUMBER "); scanf("%d",&g); printf("\nENTER SECOND NUMBER "); scanf("%d",&h); remainder=g%h; quotient=g/h; printf("REMAINDER=%d",remainder); printf("\nQUOTIENT=%d",quotient); break; case 5: int j,k,power=0; printf("FIRST NUMBER IS BASE AND SECOND IS POWER\n"); printf("ENTER FIRST NUMBER "); scanf("%d",&j); printf("\nENTER SECOND NUMBER "); scanf("%d",&k); power=pow(j,k); printf("POWER VALUE IS=%d",power); break; case 6: float l,squareroot=0; printf("ENTER THE VALUE OF WHICH WE HAVE TO FIND SQUARE ROOT "); scanf("%d",&l); squareroot=sqrt(l);

printf("THE SQUARE ROOT =%d",squareroot); break; case 7: float m; float n; printf("ENTER THE VALUE FOR WHICH WE HAVE TO FIND INVERSE scanf("%f",&m); n=1/m; printf("INVERSE IS =%f",n); break; case 8: int fact=1,o,p,q; printf("ENTER THE VALUE FOR WHICH WE HAVE TO FIND FACTORIAL scanf("%d",&o); for(p=1;p<=o;p++) { fact=fact*p; } printf("FACTORIAL =%d",fact); break; case 9: exit(0); default: printf("PLEASE ENTER THE VALID OPTION !"); sound(1000); } getch(); } ");

");

TESTING THE OUTPUT OF MY PROJECT

{1} ADDITION {2} SUBTRACTION {3} MULTIPLICATION {4} DIVIDE {5} POWER {6} SQUARE ROOT {7} INVERSE {8} FACTORIAL {9} EXIT

IT WILL WORKS ACCORDING TO THE NO.ENTER BY USER.

FUTURE SCOPE OF PROJECT:

My project is calculator. It will surely help in calculating the calculations . It will reduce manual labour and will be more machine oriented, thus will also help in reducing large calculation easly . It will reduce manual labour for calculating the scientific calculation.

It will be very good project in the future. Because of:1. It is very simple to use. 2. It is user friendly. 3. We can simply perform a calculation .

BIBLIOGRAPHY

www.en.wikipedia.org Google search

Let Us C By YASHAVANT KANETKAR Programming in ANSIC BY BALGOLSWAMIN Programming in C BY TATA MACGRAWAL PUB.

Das könnte Ihnen auch gefallen