وبلاگ شخصی مستر حاج رضا

وبلاگ شخصی مستر حاج رضا

در اینجا میخوام فقط بنویسم! درهم و نامربوط! همه چیز
وبلاگ شخصی مستر حاج رضا

وبلاگ شخصی مستر حاج رضا

در اینجا میخوام فقط بنویسم! درهم و نامربوط! همه چیز

اولین برنامه ای که نوشتم

این اولین برنامه ای است که نوشتم! 

یه برنامه خیلی ساده و به درد نخور! محاسبه مساحت مربع، مستطیل و دایره در صورتی که شما یک عدد رو وارد کنید و اون عدد یکی از ضلعهای مربع و عرض مستطیل و شعاع دایره باشد! 

کدش رو اینجا یادگاری میزارم. البته مجبورم تعاریف مربوط به خودم و استادم رو پاک کنم 



// Author: Reza 

// Program: This program calculates the perimeter and area of rectangle, Square, and circle

// Input: The Value x (is a side of square, width and half of rectangle, and radius of circle)

// Output: the area of the Square, Rectangle, and Circle 

//Class: C++

//Proffessor: B

// Assignment 1

//Revision: 4

//Date: 04/01/2018



//This header for compile the file and store it

#include "stdafx.h"


// this header needed for int, cout, and cin

#include <iostream>


// This header for Console input and output

#include <conio.h>


// this header needed for showing the double and decimal points

#include <iomanip>



using namespace std;


int main()

{

// Tell the User what this program does

cout << "Hello," << endl;

cout << "This Program Calculates the area of a square, rectangle, and circle according to value of x." << endl;


// Declare the Variable

int x;


//propmpt the user to enter the value x

cout << "Please enter the value for x:" << endl;


// input the value x

cin >> x;


// Calculate the Square Area

int squarearea = x * x;


// Calculate the Rectangle Area

int rectanglearea = (2 * x)*x;


// Calculate the Circle Area

double circlearea = 3.14159*x*x;



// Display the Square Area

cout << "\nThe area of the Square with side " << x << " is:" << squarearea << endl;


// Display the Rectangle Area

cout << "\nThe area of the Rectangle with side " << x << " is:" << rectanglearea << endl;


// Force computer to show decimal point

cout << fixed << showpoint;

// Set the decimal points into Three digits

cout << setprecision(3);


// Display the Corcle area (after setting the decimal point)

cout << "The area of the Circle with side " << x << " is:" << circlearea << endl;


// Prompt the user press any key to exit the program 

cout << "\nPress Any Key to continue ....";


//exit the program 

_getch();


//return 0 to show end of execution

return 0;

}