Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,167,200 members, 7,867,488 topics. Date: Friday, 21 June 2024 at 04:59 PM

C Programming - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / C Programming (780 Views)

Introduction To C++ Programming (Video Tutorial For Beginners) / C Programming Challenge To Be Solved Under 10 Minutes (2) (3) (4)

(1) (Reply) (Go Down)

C Programming by BheeTee: 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;

}

1 Like

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: 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)

An Issue.... / I Built My First Iphone App In 28 Days. This Is My Video Diary. / Need Help On Networking

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 19
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.