#include <stdio.h>
#include <stdlib.h>
#define calc(a,b) (a*b)/(a-b)
void calculate(){
int a = 20, b = 10;
printf("%f\n", calc(a+4,b-2));//output 0.00000
}
what to do to print the actual answer, 4.83.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The problem here is with your datatypes which are ints, not with format-specifiers. Integer division is always truncated to the whole numbers. You should consider changing your variables to float instead of int.
Try this: