close
دانلود فیلم
برنامه محاسبه مربع و مکعب يک عدد


#include <iostream.h>

float square_num(float num);
float cube_num(float num);
int main()
{
    int choice;
    float number, answer;
    cout << "Would you like to (1) square a number or (2) cube a number ? n";
    cout << "Please press the number of your choice 1 or 2 n";
    cin >> choice;
    cout << "Please enter your number n";
    cin >> number;
    if (choice == 1 ){
      answer = square_num(number);
    }
    else {
       answer = cube_num(number);
     }
     cout << "Your answer is " << answer << "n";
}
float square_num(float num)
{
    float a;
     a = num * num;
      return a;
}
float cube_num(float num)
{
    float a;
    a = num * num * num;
    return a;
}


به کانال تلگرام سایت ما بپیوندید