Good day everyone,
Hope you could help me on this one
The program is running but the result is far from what I want please help me... TIA
Like this one:
Input:
------------------------------------
Enter first number: 7
Enter second number: 45
------------------------------------
Output:
------------------------------------
7.45
7.00
------------------------------------
which should be my target output is:
------------------------------------
7.45
7.45
------------------------------------
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
main()
{
char str1[80],str2[80];
int num1, num2;
float num3;
clrscr();
printf("Enter first number: ");
scanf("%d",&num1);
printf("Enter second number: ");
scanf("%d",&num2);
sprintf(str1,"%d.",num1);
sprintf(str2,"%d",num2);
strcat(str1,str2);
printf("%s\n",str1);
num3 = atoi(str1);
printf("%.2f",num3);
getch();
}
Thanks in advanced again!:)