MVPS's Rajarshi Shahu Maharaj Polytechnic, Nashik: Department of Information Technology
MVPS's Rajarshi Shahu Maharaj Polytechnic, Nashik: Department of Information Technology
MVPS's Rajarshi Shahu Maharaj Polytechnic, Nashik: Department of Information Technology
“Programming in C”
(22226)
MICROPROJECT
ON
“HUMAN CALCULATOR”
GUIDED BY
Mrs. S. S. Tile
1
MAHARASHTRA STATE BOARD OF TECHNICAL
EDUCATION
Certificate
Seal of
institute
2
SUBMITTED BY
3
INDEX
1) Abstract 6
Chapter no.1
2) (Introduction) 7
Chapter no.2
3) (Coding and their output) 12
Chapter no.3
4) 15
(Algorithm & Flowchart)
5) Conclusion
19
6) References 20
1 Syntax of Function 7
4
2 Difference of function 8
3 Syntax of Switch Case 10
4 Output of calculator 14
LIST OF FIGURE
ABSTRACT
5
Our micro project based on the Human calculator. We have use many concept
like function, Do while loop, switch case etc. This project is user friendly and can easily be
understood by the user. In the coding section of this project we define the detail coding of
our project & we also paste the screen shot of basic coding. The whole project is developed
in C programming language, different variables and strings have been used for the
development of this project .this is a mini project so it contains a bit less features. it is easy
to operate and understood by users .this project can help students understand the operations
that are involved in designing Calculator software.
We will see that the C is the basic for creating program. Nowadays programs
are most important. Everyone knows about program. So, we will see that the development
of program help of various syntax. C helps you to understand working of a program and to
enhance your Programming logic. It also helps to visualize working of the computer.
Chapter No. 1
INTRODUCTION
6
C is the general purpose structured programming language designed and
written by the Dennis Ritche at AT & T’s Bell Laboratories of USA in 1972. C is a
middle level language because it combines both the features of high –level language and
low level language. C helps you to understand working of a program and to enhance your
Programming logic. It also helps to visualize working of the computer.
1. Function
Definition:-
A function is a group of statements that together perform a task. Every C program has
at least one function, which is main(), and all the most trivial programs can define additional
functions. You can divide up your code into separate functions. How you divide up your
code among different functions is up to you, but logically the division is such that each
function performs a specific task. A function declaration tells the compiler about a
function's name, return type, and parameters. A function definition provides the actual body
of the function. The C standard library provides numerous built-in functions that your
program can call. For example, strcat() to concatenate two strings, memcpy() to copy one
memory location to another location, and many more functions. A function can also be
referred as a method or a sub-routine or a procedure, etc.
Syntax:-
7
Function Declaration Function Definition
Contains the function name, parameters list, Contains the function name, parameter list,
return type return type, function body.
Parameter used in c :-
#include <stdio.h>
int sum(int a, int b)
{
int c=a+b; return c;
}
int main( )
{
int var1 =10; int var2 = 20;
int var3 = sum(var1, var2);
printf("%d", var3);
return 0;
}
b) Formal parameter:-
These variables are called the formal parameters of the function. Formal
parameters behave like other local variables inside the function and are created upon
8
entry into the function and destroyed upon exit. While calling a function, there are
two ways in which arguments can be passed to a function
Types of function :-
Here function will accept data from the calling function as there are
arguments, however, since there is no return type nothing will be returned to the
calling program. So it’s a one-way type communication.
Function with arguments and one return value means both the calling function and
called function will receive data from each other. It’s like a dual communication.
2. Switch case:-
Definition:-
9
A switch statement tests the value of a variable and compares it with multiple
cases. Once the case match is found, a block of statements associated with that particular
case is executed. Each case in a block of a switch has a different name/number which is
referred to as an identifier. The value provided by the user is compared with all the cases
inside the switch block until the match is found. If a case match is found, then the default
statement is executed, and the control goes out of the switch block.
Syntax:-
10
2. Do while loop:-
Definition:-
The do while loop is exit controlled loop. That is the condition is the checked at
the end of loop. Hence even if the condition does not satisfy, the loop statements will
be executed at least once.
Syntax:-
do
{
Statement 1;
}while(condition 1);
11
Chapter No. 2
CODING & THEIR OUTPUT
#include <stdio.h>
#include<conio.h>
Void main()
{
int ch;
int n1, n2;
char c;
clrscr;
do
{
printf("\t\t\t ----------------------------------------------------\n");
printf(“\t\t\t WELCOME TO SIMPLE CALCULATOR\n");
printf("\t\t\t ----------------------------------------------------\n");
printf("\t\t\t Enter first number\n");
scanf("%d", &n1);
printf("\t\t\t Enter second number\n");
scanf("%d", &n2);
printf("\t\t\t ----------------------------------------------------\n");
printf("\t\t\t Menu of Calculator\n");
printf("\t\t\t 1.Addition\n");
printf("\t\t\t 2.Subtraction\n");
printf("\t\t\t 3.Multiplication\n");
printf("\t\t\t 4.Division\n");
printf("\t\t\t 5.Remainder\n");
printf("\t\t\t Enter your choice:\n");
printf("%d",&ch);
switch(ch)
{
case '1':
add(n1, n2);
break;
12
case '2':
sub(n1, n2);
break;
case '3':
mult (n1, n2);
break;
case '4':
div(n1, n2);
break;
case '5':
rem(n1, n2);
break;
default:
printf ("\t\t\t\Please enter the correct input\n");
}
printf(“\t\t\t Do you want to continue?(y/n)\n”);
scanf(“%c”,&c);
printf("\t\t\t ----------------------------------------------------\n");
}while(getch()==’y’||getch()==’Y’);
printf(“\t\t\t Thanks for using Calculator\n”);
getch;
}
13
{
int result= n1/n2;
display(n1,n2,’/’,result);
}
Output:-
Chapter No. 3
14
ALGORITHM & FLOWCHART
Algorithm:-
default:
Please enter correct input.
Step 14:- Do you want to continue?(y/n)
If y then program will continue.
Else display message “Thanks for using Calculator.”
15
Step 15:- Stop.
Step 16:- Format of displaying output.
n1,ch,n2,result.
Step 17:- add(n1,n2)
Result= n1+n2
Step 18:- Sub(n1,n2)
Result= n1-n2
Step 19:- mult (n1,n2)
Result= n1*n2
Step 20:- div(n1,n2)
Result= n1/n2
Step 10:- rem(n1,n2)
Result=n1-(n1/n2)*n2
Flowchart:-
16
17
18
CONCLUSION
It was a great experiences to design and implement the Human calculator by
using switch case and function using programming language c and to work on its
documentation. While working on this project .I have learned many things especially how to
apply concept in modelling of real world system. It also helpful me in getting in the better
understanding of basic programming concept of C language such as function, switch case.
19
REFERENCES
https://codeforwin.org/2015/06/c-program-to-create-simple-calculator-using-switch-
case.html
PCI Textbook
https://aticleworld.com/calculator-in-c/
20