Write A C Program To Simulate A Simple Calculator Using Switch Statement
Write A C Program To Simulate A Simple Calculator Using Switch Statement
Write A C Program To Simulate A Simple Calculator Using Switch Statement
AIM:
#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
11
BONACCI SERIES
AIM:
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