Write a simple code that multiplies two numbers, 7.3 and 21. Then display the result in the serial monitor.
Answers
Explanation:
The outlines given in question statement can be written in many programming languages. The below program would be written in C language, which is one of the basic computer languages
Program code
#include<stdio.h>
int main (void)
{
int a;
int b;
int output;
a = 7.3
b = 21
output = a x b;
printf("The multiplication result of numbers is %i", output)
return output
}
Answer:
1. Program in C programming language
#include<stdio.h>
int main()
{
float num,num1, multiply;
printf("Enter First Number : ");
scanf("%f", &num);
printf("Enter Second Number : ");
scanf("%f",&num1);
multiply=num*num1;
printf("Multiplication is %.2f",multiply);
return 0;
}
2. Program in C++ programming language
#include <iostream>
using namespace std;
int main()
{
double num, num1, Multiplication;
cout << "Enter first number: ";
cin >> num;
cout << "Enter second number: ";
cin >> num1;
Multiplication = num * num1;
cout << "Multiplication is " << Multiplication;
}
3. Program in Java programming
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Enter first number: ");
float num = scan.nextFloat();
System.out.print("Enter second number: ");
float num1 = scan.nextFloat();
scan.close();
float multiplication = num*num1;
System.out.println("Multiplication is "+multiplication);
}
}
4. Program in Python programming language
num=float(input("Enter the first number: "))
num1=float(input("Enter the second number: "))
multiplication=num*num1;
print("Multiplication is ",multiplication)
5. Program in QBASIC programming language
CLS
PRINT "Enter first number"
INPUT NUMBER1
PRINT "Enter second number"
INPUT NUMBER2
MULTIPLICATION = NUMBER1 * NUMBER2
PRINT "The multiplication is:", MULTIPLICATION
END
Note=> Program code asked in question is written in five languages above and they will ask user to input the numbers to multiply.