WAP to read two floating point numbers using a scanf statement, assign their sum to an integer variable and then output the values of all the three variables

//E Balagurusamy, Programming in ANSI C,4E
//Exercise 2.8, p51

//Note:
//. comments with //scaff indicate scaffolding code to help during development of code
//. can be safely commented out/removed (in production code)
#include <stdio.h>
#include <conio.h>
int main (void)
{
    float real_first=0.0, real_second=0.0;
    int sum=0;


    printf("\nEnter the two real numbers : ");
    scanf("%f%f",&real_first, &real_second);
    //adding and storing in int
    sum = real_first + real_second;
    printf("\n\n===OUTPUT===");
    printf("\n\nFirst real number  : %f", real_first);
    printf("\nSecond real number : %f", real_second);
    printf("\nSum as stored in an int variable : %d", sum);
    getch();
    return 0;
}

Comments