#include <stdio.h>
void simpleInterest (double Princ, double Rate, int Time)
{
double value;
value = Princ*Rate*Time;
return value;
}
int main (int argc, char*argv[])
{
printf("the value is %d", simpleInterest (100,0.01,5))
}
I can't seem to find what is wrong with my code, i'm really new to c just started today actually, i get an error code saying:
simpleInterest: warning return with a value, in function returning void [enabled by default]
what does that actually mean ? what is actually wrong with my code ?
void simpleInterest (double Princ, double Rate, int Time)
{
double value;
value = Princ*Rate*Time;
return value; //void function should not return anything
}
You need to declare and define your function with double return type.
double simpleInterest (double Princ, double Rate, int Time)
{
double value;
value = Princ*Rate*Time;
return value;
}
When you return double you should use %f
format specifier in printf statement.Other wise it invokes undefined behavior.
printf("the value is %f", simpleInterest (100,0.01,5))