Search

Write a C Program to Multiply Two Numbers using User input?



Write a C Program to Multiply Two Numbers using User input?

#include <stdio.h>

int main()

{

double firstNumber, secondNumber, product;

printf("Enter two numbers: ");

/* Stores two floating point numbers in variable firstNumber and secondNumber respectively */

scanf("%lf %lf", &firstNumber, &secondNumber);

// Performs multiplication and stores the result in variable productOfTwoNumbers

product = firstNumber * secondNumber;

/* Result up to 2 decimal point is displayed using %.2lf */

printf("Product = %.2lf", product);

return 0;

}


Output:

Enter two numbers: 2.4 1.12

Product = 2.69


Related Topic: Write a C Program to Add Two Integers using User input?


#Interview #Preperation #Placement #OffCampusing #Engineering #OnCampus #PrivateJobPreperation #JobPreperation#CodingPreperation #AMCAT #Automata #JobsforGraduates #HighestPayingJobsforGraduates

#coding #codinglife #codingisfun #codingproblems #CoffeeWithCodes #CWC #Cprogramming #cprogramminglanguage #competitiveprogramming