I am writing a program to add two numbers. But instead of adding, the result is some thing else like z=0.0000 or z=4209163 while my two numbers to be added are 10 and 20. Please help.
Printable View
I am writing a program to add two numbers. But instead of adding, the result is some thing else like z=0.0000 or z=4209163 while my two numbers to be added are 10 and 20. Please help.
Show your program.
My program is:
Code:#include<stdio.h>
#include<conio.h>
void main()
{
float n1,n2,ans;
printf("Enter the First number\n");
scanf("%f",&n1);
printf("Enter the Second number\n");
scanf("%f",&n2);
ans=n1 + n2;
printf("Your Answer is -: %.3f",&ans);
}
Drop the & from the printf.
main returns int, not void.