Programming

Just another WordPress.com weblog

CT211-C Program คำนวณหาพื้นที่วงกลม,สี่เหลี่ยมผืนผ้า,สี่เหลี่ยมจัตุรัส

แสดงความเห็นโดย จั่น บน กรกฎาคม 14, 2008

#include <stdio.h>

#include <conio.h>

#include <iostream.h>

void main(){

clrscr();

float area;
int m, a, b;

cout << “1.Area of Circle\n2.Area of Rectangular\n3.Area of Square\n99.Stop\n”;
cout << “Press “;
cin >> m;

while(m!=99){

if(m>=1 && m<=3){

switch(m){

case 1:

cout << “\nInput Radius “;

cin >> a;

area = (22.0/7) * a * a;

break;

case 2:

cout << “\nInput Width “;
cin >> a;
cout << “Input Long “;
cin >> b;

area = a * b;

break;

case 3:

cout << “\nInput Width “;
cin >> a;

area = a * a;

break;

default:

break;

}

cout << “Area ” << area << “\n”;

}else{

cout << “Invalid Data. Try again (Choose Integer 1-3 or 99 Exit)\n”;

}

cout << “Press “;
cin >> m;

}

cout << “End Program. Bye :) \n” << “Press Enter to Exit”;
getch();

}

ใส่ความเห็น

XHTML: คุณสามารถใช้แท็กเหล่านี้ได้: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>