₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,331,092 members, 8,448,615 topics. Date: Monday, 20 July 2026 at 03:31 PM

Toggle theme

C Programming - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingC Programming (878 Views)

1 Reply (Go Down)

C Programming by BheeTee(op): 12:24am On Dec 16, 2014
Sorry friends, I would like you to help me out on this assignment given to us by our lecturer,
he told us to create a calculator "C Program" that can perform the arithmetic operations (+,-,*,/,%) and can accept more than two inputs
(e.g 2*3-6/4).
We are to submit the assignment by Thursday 18 dec.
pls don't let me down
Re: C Programming by umaryusuf(m): 6:57am On Dec 16, 2014
BheeTee:
Sorry friends, I would like you to help me out on this assignment given to us by our lecturer,
he told us to create a calculator "C Program" that can perform the arithmetic operations (+,-,*,/,%) and can accept more than two inputs
(e.g 2*3-6/4).
We are to submit the assignment by Thursday 18 dec.
pls don't let me down
This should be very easy to solve. Even a simple Google search on this topic save the day.

/* Source code to create a simple calculator for addition, subtraction, multiplication and division using switch...case statement in C programming. // source: http://www.programiz.com/c-programming/examples/calculator-switch-case/

# include <stdio.h>
int main()
{
char o;
float num1,num2;
printf("Enter operator either + or - or * or divide : "wink;
scanf("%c",&o);
printf("Enter two operands: "wink;
scanf("%f%f",&num1,&num2);
switch(o) {
case '+':
printf("%.1f + %.1f = %.1f",num1, num2, num1+num2);
break;
case '-':
printf("%.1f - %.1f = %.1f",num1, num2, num1-num2);
break;
case '*':
printf("%.1f * %.1f = %.1f",num1, num2, num1*num2);
break;
case '/':
printf("%.1f / %.1f = %.1f",num1, num2, num1/num2);
break;
default:
/* If operator is other than +, -, * or /, error message is shown */
printf("Error! operator is not correct"wink;
break;
}
return 0;

}
Re: C Programming by HouseOfBalloons(f): 10:16am On Dec 16, 2014
The person above me has already answered. Its a very simple program
Re: C Programming by BheeTee(op): 1:01pm On Dec 16, 2014
thank U im very grateful buh i need the one that can take in more than two operator/operand at a time
Re: C Programming by asalimpo(m): 11:34pm On Dec 18, 2014
you want something 'algebraic' ? That calculates based on operator precedence? E.g * computes before + / -, so that e.g 4+5*3 will compute as 4+(5*3) and not in the straight order it was written?
1 Reply

Introduction To C++ Programming (Video Tutorial For Beginners)C Programming Challenge To Be Solved Under 10 Minutes234

SETTING UP Events In Laravel 5.1Microsoft BASIC Programming TutorialsGraphic Designer Needed