I tried this code and it works properly:
#include <stdlib.h>
#include <stdio.h>
double addition(double a,double c);
double subtraktion(double a, double c);
double multiplikation(double a, double c);
double division(double a, double c);
int main()
{
double z=0, a, c;
char b;
printf("Insert your Numbers to calculate!");
scanf("%lf", &a);
scanf("%c", &b);
scanf("%lf", &c);
if (b == '+')
{
z = addition(a, c);
}
if (b == '-')
{
z = subtraktion(a, c);
}
if (b == '*')
{
z = multiplikation(a, c);
}
if (b == '/')
{
z = division(a, c);
}
printf("Result: %lf\n", z);
}
double addition(double a, double c)
{
double z;
z = a + c;
return(z);
}
double subtraktion(double a, double c)
{
double z;
z = a - c;
return(z);
}
double multiplikation(double a, double c)
{
double z;
z = a*c;
return(z);
}
double division(double a, double c)
{
double z;
z = a / c;
return(z);
}
Compile and then in input type: 3+2 [Press enter] and it shows the exact result!
P.S. I deleted the 'custom' header and then used the simple scanf function. I deleted the system("pause") too because I'm not under Visual Studio. (so you may need that)
So what I've done is:
- Deleted your custom header #include "stdafx.h"
- Edited the scanf_s to scanf(...)
- Added z = functions()
- printf(...\n) // not necessary
And it works.