C++教程
C++控制语句
C++函数
C++数组
C++指针
C++对象
C++继承
C++多态
C++抽象
C++常用
C++ STL教程
C++迭代器
C++程序

C++ 两个数字相乘的程序

两个数字相乘的C++程序

在这个程序中,要求用户输入两个数字(浮点数)。然后,将这两个数字的乘积存储在一个变量中并显示在屏幕上。

两个数字相乘的C++程序

#include <iostream>
using namespace std;
int main() {
  double num1, num2, product;
  cout << "Enter two numbers: ";
  // stores two floating point numbers in num1 and num2 respectively
  cin >> num1 >> num2;
 
  // performs multiplication and stores the result in product variable
  product = num1 * num2;  
  cout << "Product = " << product;    
    
  return 0;
}
输出
Enter two numbers: 3.4
5.5
Product = 18.7
在这个程序中,要求用户输入两个数字。用户输入的这两个数字分别存储在变量 num1num2 中。
然后,计算 num1num2 的乘积,并将结果存储在变量 product 中。
最后, product 显示在屏幕上。
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4