Programming Tutorials

(追記) (追記ここまで)

Calculating total based on the given quantity and price in C++

By: Jeffrey in C++ Tutorials on 2012年03月16日 [フレーム]

This simple C++ program shows how to calculate total based on the given quantity and price.

#include <iostream>
using namespace std;
// main() function with no argument and int return value-
int main(void)
{
// variables declaration and their respective the data types
int quantity;
float price, total;
cout<<"testing 1..2..3..\n";
// standard output - read from user input
cout<<"\nEnter the item's price: RM ";
// standard input - store user's input at variable price
cin>>price;
cout<<"\nEnter the item's quantity: ";
cin>>quantity;
// multiply quantity and price store the result at total-
total = quantity * price;
// print the total value
cout<<"\nTotal price = RM "<<total<<endl;
return 0;
}



(追記) (追記ここまで)


Add Comment

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!
(追記) (追記ここまで)
(追記) (追記ここまで)

AltStyle によって変換されたページ (->オリジナル) /