Professional Documents
Culture Documents
Sujeet D DSL-1
Sujeet D DSL-1
: 51 Div: B
Branch: CSE(IoT)
Date of Performance: 21st July, 2023 Subject: Data Structure Experiment No. : 1
Aim:
To write a program for calculator using switch case.
Theory:
C language is the base of all programming languages. The operating system (OS) is built using C.
An entity that may vary during the program execution is called a variable.
Syntax is a combination of data type and variable name. eg. int a; int z; etc.
Types of variable:
i) Global
ii) Local
A word whose meaning has already been explained to the compiler is known as Keywords.
An entity does not vary during the program execution is called a Constant.
Operators:
i) Increment and decrement operators: It is used to increment the value of a variable by 1. It is used to
decrease the operand values by 1. The increment operator is represented as the double plus (++) symbol. The
decrement operator is represented as the double minus (--) symbol.
Name: Sujeet D Roll No. : 51 Div: B
Branch: CSE(IoT)
Date of Performance: 21st July, 2023 Subject: Data Structure Experiment No. : 1
ii) Bitwise operators: This is an operator used to perform bitwise operations on bit patterns or binary numerals
that involve the manipulation of individual bits. These are used in: Communication stacks where the
individual bits in the header attached to the data signify important information.
iii) Assignment operators: In this, = assigns the value of its right-hand operand to a variable, a property, or an
indexer element given by its left-hand operand. The result of an assignment expression is the value assigned
to the left-hand operand.
iv) Logical operators: These are generally used for combining two or more relational statements. They return
Boolean values. The logical operators are used primarily in the expression evaluation to make a decision.
These operators allow the evaluation and manipulation of specific bits within the integer.
v) Relational operators: These are the operators used to create a relationship and compare the values of two
operands
vi) Special operators: In the C programming language, special operators are used to perform specific operations
that cannot be done with normal arithmetic or logical operators. These operators are special because they
have their own unique syntax and functionality.
vii) Conditional operators: This is the one and only ternary operator in the C programming language. It can be
used as an alternative for if-else condition if the 'if else' has only one statement each
viii) Arithmetic Operators: These are the type of operators in C that are used to perform mathematical
operations in a C program. They can be used in programs to define expressions and mathematical formulas.
Name: Sujeet D Roll No. : 51 Div: B
Branch: CSE(IoT)
Date of Performance: 21st July, 2023 Subject: Data Structure Experiment No. : 1
Program:
#include<stdio.h>
{int sol;
sol=a+b;
return(sol);
{int sol;
sol=a-b;
return(sol)
{int sol;
sol=a*b;
return(sol);
{int sol;
sol=a*b;
return(sol);
}
Name: Sujeet D Roll No. : 51 Div: B
Branch: CSE(IoT)
Date of Performance: 21st July, 2023 Subject: Data Structure Experiment No. : 1
int main()
{int opt,a,b,sol,rem;
printf("enter a choice:");
scanf("%d",&opt);
switch(opt)
case 1:
scanf("%d%d",&a,&b);
sol=add(a,b);
break;
case 2:
scanf("%d%d",&a,&b);
sol=suub(a,b);
break;
case 3:
scanf("%d%d",&a,&b);
sol=mul(a,b);
break;
Name: Sujeet D Roll No. : 51 Div: B
Branch: CSE(IoT)
Date of Performance: 21st July, 2023 Subject: Data Structure Experiment No. : 1
case 4:
printf("enter divident:");
scanf("%d",&a);
printf("enter divisor:");
scanf("%d",&b);
sol=dvn(a,b);
rem=a-(b*dvn(a,b));
break;
default:
printf("invaliid choice!");
break;
return(0);
Output:
Name: Sujeet D Roll No. : 51 Div: B
Branch: CSE(IoT)
Date of Performance: 21st July, 2023 Subject: Data Structure Experiment No. : 1
Result:
Implemented Successfully