0% found this document useful (0 votes)
43 views2 pages

Write A C Program To Simulate A Simple Calculator Using Switch Statement

The program creates a simple calculator that takes operator and two numbers as input and displays the result. It uses switch statement to perform calculation based on operator.

Uploaded by

Utpal Kant
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)
43 views2 pages

Write A C Program To Simulate A Simple Calculator Using Switch Statement

The program creates a simple calculator that takes operator and two numbers as input and displays the result. It uses switch statement to perform calculation based on operator.

Uploaded by

Utpal Kant
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/ 2

Write a C program to simulate a simple calculator using switch statement.

AIM:

To simulate a simple calculator using switch statement.


PROGRAM:

#include<stdio.h>
int main ()
{
int a, b, result;
char op;
printf ("Enter an expression: ");
scanf ("%d%c%d", &a, &op, &b);
switch(op)
{
case '+':
result = a + b;
break;
case '-':
result = a - b;
break;
case '*':
result = a * b;
break;
case '/':
result = a / b;
break;
}
printf ("Result = %d", result);
return 0;
}
Input:
Enter an expression: 35*65
Output:
Result=2275

RESULT: A simple calculator is created and calculated.

11
BONACCI SERIES

Write a C program to Find Fibonacci Series Up to 100.

AIM:

To Find Fibonacci Series Up to 100.

PROGRAM:

#include<stdio.h>
int main ()
{
int n1=0,n2=1,n3,i,number;
printf ("Enter the number of elements:");
scanf("%d",&number);
printf ("\n%d %d",n1,n2);
for(i=2;i<number;++i)
{
n3=n1+n2;
printf (" %d",n3);
n1=n2;
n2=n3;
}
return 0;
}

Input:
Enter the number of terms: 15
Output:
Fibonacci Series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34,55,89,144,233,377

RESULT: Fibonacci Series Up to 100 has been found.

You might also like