我正在處理一個小問題,並花了好幾個小時試圖弄清楚我做錯了什麼。使用Dev ++編譯器,它有時會有一些神祕的錯誤信息。關於函數和錯誤檢查的新手C++問題
我試圖讓體積計算功能,並得到它的工作,但我有2個小尼特。我解決這個問題後,將工作在錯誤檢查。
隨着函數的增加,出於某種原因現在使用dev ++,程序不會暫停(按任意鍵繼續)。
卷是空白而不是數字。
感謝 PC
// The purpose of this program is to determine the Volume of a
// square-based pyramid after the user inputs the Area and
// the Height.
#include <iostream>
#include <iomanip>
using namespace std;
double calcvolume(double a, double h)
{
double volume;
volume = (a * h)/3;
return (volume);
}
int main()
{
double area, height, volume; // declare variables
cout << "Please enter the Area of the Square-based pyramid:"; // requests users input
cin >> area; // assigns user input to area
cout << "Please enter the Height of the Square-based pyramid:"; // requests user input
cin >> height;
// assigns user input to height
cout << "Area= " << area << "\n"; // Prints user input for area
cout << "Height= " << height << "\n";
calcvolume(area,height);
cout << "Volume= " << fixed << showpoint << setprecision(2) << volume << "\n"; // Prints resolution to the formula stored in volume
system("pause"); // forces DOS window to pause to allow user to utilize program
return 0;
}
如果您在編寫函數進行計算時需要幫助,請發佈您已經提出的內容,我們將從此處爲您提供幫助。 – luke 2010-01-27 18:59:47
我們希望看到你寫的內容無效 - 我們無法修復工作代碼。 – 2010-01-27 19:01:13
如果你需要幫助來弄清楚爲什麼事情不起作用,那麼顯示什麼是有效的,而不是沒有用的。 – 2010-01-27 19:01:57