Logo 
Search:

Assembly Language Forum

Ask Question   UnAnswered
Home » Forum » Assembly Language       RSS Feeds

calculator

  Asked By: Meril    Date: Oct 03    Category: Assembly Language    Views: 2914
  

hi..
i really need a program that makes u input a string (5+3) and outputs the result (8) of the string.
anyone can please help me, please??

input: 5+3
output: 8

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Muhammed Athil     Answered On: Nov 28

I have a solution.. You must put a space b/w number and operator while running program...




Program
--------

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
char o;// is used to store operator
printf("please enter the numbers and the operator\nformat\n-------\nno1<space>opr<space>no2\n");
scanf("%d %c %d",&a,&o,&b);
clrscr();
if (o=='+')
{
printf("please enter the numbers and the operator\nformat\n-------\nno1<space>opr<space>no2\n");
printf("%d %c %d = %d",a,o,b,a+b);
}
if (o=='-')
{
printf("please enter the numbers and the operator\nformat\n-------\nno1<space>opr<space>no2\n");
printf("%d %c %d = %d",a,o,b,a-b);
}
if (o=='*')
{
printf("please enter the numbers and the operator\nformat\n-------\nno1<space>opr<space>no2\n");
printf("%d %c %d = %d",a,o,b,a*b);
}
if (o=='/')
{
printf("please enter the numbers and the operator\nformat\n-------\nno1<space>opr<space>no2\n");
printf("%d %c %d = %d",a,o,b,a/b);
}

getch();
}








Thankyou
for any help
smartathil@gmail.com

 
Didn't find what you were looking for? Find more on calculator Or get search suggestion and latest updates.




Tagged: