Code:
// Please format your code. It is unreadable otherwise.
#include <stdio.h>
int main()
{
float num1=0.0, num2; // Specs called for type double, why is this float?
char oper, a, exit;
printf("Calculator is on.\n");
do{
while(a!= 'r') // _a_ is uninitialized, Universe ends here.
// Specs also said that it can be either 'r' or 'R';
// have a look at toupper() or tolower() function
// and think about how you can use either here.
{
scanf("%c", &oper);
scanf("%f",&num2);
if(oper=='+')
{
printf("result= %lf\n", num2+num1);
num1=num2+num1;
}
else if (oper=='-')
{
printf("result= %lf\n", num2-num1);
num1=num2-num1;
scanf("%c",&a);
}
scanf("%c",&a);
}
printf("final result is %d\n",num1); // %d is the format specifier for integers
// floats and doubles have their own -- %f
printf("would you like to go again?\n");
fflush(stdin); // Don't, just don't use fflush() with input streams
// for all intents and purposes, it only work for output.
scanf("%c",&exit);
} while (exit!='n');
return 0;
}