# Thread: simple calculator

1. ## simple calculator

I made some simple basix calculator in dev c++ like c program and I would like to change it a bit. Does anyone can help me make that this program will calculate like this:
you write 5*5 and it will write 25 and it will set in you new line and you will be able to write numbers again and it will calculate it again.
Now program calculate it and it just close after that.
It look like this:
Code:
```#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{float a,b,r;
char op;
scanf("%f%c%f", &a, &op, &b);
switch(op)
{case '+':r=a+b;
printf("%f", r);
break;
case '-':r=a-b;
printf("%f", r);
break;
case '*':r=a*b;
printf("%f", r);
break;
case '/':r=a/b;
printf("%f", r);
break;
default: printf ("Nekaj ne delas prav"); }

system("PAUSE");
return 0;
}

#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{float a,b,r;
char op;
scanf("%f%c%f", &a, &op, &b);
switch(op)
{case '+':r=a+b;
printf("%f", r);
break;
case '-':r=a-b;
printf("%f", r);
break;
case '*':r=a*b;
printf("%f", r);
break;
case '/':r=a/b;
printf("%f", r);
break;
default: printf ("Nekaj ne delas prav"); }

system("PAUSE");
return 0;
}```
Any idea what do I have to change to don't stop after 1st calculation ?

Symcy

2. You posted the code twice for some reason.

Can you apply some of the ideas from here: Cprogramming.com Tutorial: Loops

3. Originally Posted by whiteflags
You posted the code twice for some reason.

Can you apply some of the ideas from here: Cprogramming.com Tutorial: Loops
I double posted it because of some problems with my explorer ...
I already changed that but it comes back even if I edit that.

Popular pages Recent additions