0% found this document useful (0 votes)
15 views11 pages

VVVV

The document outlines a mini project on a calculator implemented in C programming, detailing the history and structure of the C language, as well as the project's features and source code. The calculator performs basic arithmetic operations and includes error handling for invalid inputs and division by zero. Future enhancements are suggested, including the addition of advanced operations and a graphical user interface.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views11 pages

VVVV

The document outlines a mini project on a calculator implemented in C programming, detailing the history and structure of the C language, as well as the project's features and source code. The calculator performs basic arithmetic operations and includes error handling for invalid inputs and division by zero. Future enhancements are suggested, including the addition of advanced operations and a graphical user interface.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

S.N.

S COLLEGE MOTIHARI

BABASAHEB BHIMRO AMBEDKAR BIHAR


UNIVERSITY,MUZAFFARP
A MINI PROJECT IN USING C PROGRAMING
PROJECT

CALCULATER
DATA STRUCTURE

NAME :- ABHISHEK KUMAR


Examination Roll No :-
Class Roll No :- 23
Registration No :- 166201119401423
Course :- BCA
Sem :- 1st
Paper :- 106
Collage :- S.N.S Collage

Principal signature:___________ Teacher signature :___________


INDEX
S.No. Title Page No. Teacher’s sign
Introduction to ‘C’ Language & Language Fundamentals
History of C Programming Language :
• C is a programming language which born at “AT & T’s Bell Laboratory” of USA in
1972.
• C was written by Dennis Ritchie, that’s why he is also called as father of c
programming language.
• C language was created for a specific purpose i.e designing the UNIX operating
system (which is currently base of many UNIX based OS).
• From the beginning, C was intended to be useful to allow busy programmers to get
things done because C is such a powerful, dominant and supple language
• Its use quickly spread beyond Bell Labs in the late 70’s because of its long list of
strong features.
Why Name “C” was given to Language ?
Many of C’s principles and ideas were derived from the earlier language B. (Ken Thompson was
the developer of B Language.)

• BCPL and CPL are the earlier ancestors of B Language

• CPL is common Programming Language.In 1967, BCPL Language ( Basic CPL ) was

created as a scaled down version of CPL

• As many of the features were derived from “B” Language thats why it was named as “C”.

• After 7-8 years C++ came into existence which was first example of object oriented

programming .

Summary of C Programming Language History


Summary –

1 B Language Developed By Ken Thompson

2 Operating System Developed in C UNIX

3 Developed at AT & T Bell Laboratory

4 Creator of Traditional C Dennis Ritchie

5 Year 1972
C Programming Language Timeline :

Programming Development
Developed by
Language Year

ALGOL 1960 International Group

BCPL 1967 Martin Richards

B 1970 Ken Thompson

Traditional C 1972 Dennis Ritchie

Brain Kernighan and


K&R C 1978
Dennis Ritchie

ANSI C 1989 ANSI Committee

ANSI/ISO C 1990 ISO Committee

Structures of ‘C’ Programming

Before we study the basic building blocks of the C programming language, let us look at a
bare minimum C program structure so that we can take it as a reference in the upcoming
chapters.

Hello World Example


A C program basically consists of the following parts −

• Preprocessor Commands
• Functions
• Variables
• Statements & Expressions
• Comments

Let us look at a simple code that would print the words "Hello World" –

#include <stdio.h>

int main() {
/* my first program in C */
printf("Hello, World! \n");

return 0;
}

Let us take a look at the various parts of the above program −


• The first line of the program #include <stdio.h> is a preprocessor command, which
tells a C compiler to include stdio.h file before going to actual compilation.
• The next line int main() is the main function where the program execution begins.
• The next line /*...*/ will be ignored by the compiler and it has been put to add
additional comments in the program. So such lines are called comments in the
program.
• The next line printf(...) is another function available in C which causes the message
"Hello, World!" to be displayed on the screen.
• The next line return 0; terminates the main() function and returns the value 0.
. CACULATOR PROJECT IN C DESCRIPTION

The Calculator Project in C is a console-based application that allows users to perform basic
arithmetic operations on two input numbers. The calculator supports addition, subtraction,
multiplication, and division. It incorporates fundamental programming concepts such as functions,
user input handling, and error checking.

Key Features: 1. User Input: The program prompts the user to enter an operator (+, -, *, /) and two
numerical values. The input is read from the user using the scanf function, ensuring flexibility and
ease of interaction.

2. Arithmetic Operations: The calculator performs the selected operation based on the user-
provided operator. The implemented operations include addition, subtraction, multiplication, and
division.

3. Switch Statement: The program utilizes a switch statement to determine the operation tobe
performed, enhancing code readability and maintainability.

4. Error Handling: The calculator includes basic error handling to address potential issueIt checks for
division by zero, ensuring that the program does not crash in such scenarios, and notifies the user of
the error.

5. Functions: The project is organized using functions, promoting modularity and code reusability.
Separate functions are defined for each arithmetic operation (addition, subtraction, multiplication,
division)

6. Result Display: Upon successful calculation, the program displays the result with two decimal
places, enhancing output clarity.

7. Invalid Input Handling: The program checks for invalid operators, providing an error message and
prompting the user to enter a valid operator in case of an input mismatch.

8. Clean Exit: The program returns a status code upon completion, indicating whether the execution
was successful (0) or if there were errors (non-zero)
Future Enhancements:
1. Extended Operations: Extend the calculator to support more advanced mathematical operations,
such as exponentiation, square root, etc.

2. User Interface Improvements: Consider transitioning from a console-based interface to a graphical


user interface (GUI) for a more user-friendly experience. 3. Memory Functionality: Implement
memory functions (memory store, recall) for added functionality.

4. Continuous Calculation: Introduce a loop structure to enable users to perform multiple


calculations without restarting the program.
SOURCE CODE
#INCLIDE<STDIO.H>

#INCLUDE<CONIO.H>

// Function declarations

float add(float num1, float num2);

float subtract(float num1, float num2);

float multiply(float num1, float num2);

float divide(float num1, float num2);

int main() {

char operator;

float num1, num2, result;

// Input from user

printf("devolop by UMANG KUMAR\n");

printf("Class Roll No = 31\n");

printf("Enter 1st num= ");

scanf("%f" , &num1);

printf("Enter operator (+, -, *, /): ");


scanf(" %c", &operator); // Note the space before %c to consume
any

printf("Enter 2nd num= ");

scanf("%f" , &num2);

// Perform calculation based on the operator

switch (operator) {

case '+':

result = add(num1, num2);

break;

case '-':

result = subtract(num1, num2);

break;

case '*':

result = multiply(num1, num2);

break;

case '/':

// Check for division by zero

if (num2 != 0) {

result = divide(num1, num2);

} else {

printf("Error: Division by zero\n");


return 1; // Exit with an error code

break;

default:

printf("Error: Invalid operator\n");

return 1; // Exit with an error code

// Display the result

printf("Result: %.2f\n", result);

return 0; // Exit successfully

// Function definitions

float add(float num1, float num2) {

return num1 + num2;

float subtract(float num1, float num2) {

return num1 - num2;

float multiply(float num1, float num2) {

return num1 * num2;

float divide(float num1, float num2) {


return num1 / num2;

You might also like