Write a program in C++ to calculate the volume of a cylinder

  • برمجة سي بلس بلس
  • برمجة

Write a program in C++ to calculate the volume of a cylinder.

Sample Output:

 Calculate the volume of a cylinder :                                  
-----------------------------------------                              
 Input the radius of the cylinder : 4                                  
 Input the height of the cylinder : 8                                  
 The volume of a cylinder is : 401.92

الأجوبة

#include <iostream>
using namespace std;

    int main()
    {
    	int rad1,hgt;
    	float volcy;
		cout << "\n\n Calculate the volume of a cylinder :\n";
		cout << "-----------------------------------------\n";		
        cout<<" Input the radius of the cylinder : ";
    	cin>>rad1;
		cout<<" Input the height of the cylinder : ";
    	cin>>hgt;
    	volcy=(3.14*rad1*rad1*hgt);
        cout<<" The volume of a cylinder is : "<< volcy << endl;
        cout << endl;
        return 0;
    }
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...