كود:
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main ()
{
char shape,required ;
int h, x , y , radius , l , w ,b;
{
printf("traingle\ncircle\nrectangle");
printf("enter your choic");
scanf("%c",&shape);
}
{
printf("area\nvicinity");
printf("enter your choic");
scanf("%c",&required);
}
switch(shape)
{
case 't':
case 'T':
if( required == 'a'|| required =='A')
{
printf("enter the base and the height");
scanf("%d%d",&b,&h);
printf(" the area of the traingle is = %d ",1/2*b*h);
}
else if( required == 'v' || required == 'V')
{
printf("enter the lenght of the traingle side");
scanf("%d%d",&x,&y);
printf(" the vicinity of the trainfle is = %d",x+y );
}
break;
case 'c':
case 'C':
if(required == 'a' || required == 'A')
{
printf("enter the radius of the circle");
scanf("%d",&radius);
printf("the area of the circle = %d",pow(radius,2)* 3.14);
}
else if (( required == 'v' )|| ( required == 'V'))
{
printf("enter the radius of the circle");
scanf("%d",&radius);
printf("the vicinity of the circle = %d",2*3.14*radius);
{
break;
case 'r':
case 'R':
if(( required == 'a' )||( required == 'A'))
{
printf(" enter the lenghth and the width");
scanf("%d%d",&l,&w);
printf(" the area of the rectangle = %d",l*w);
}
else if (( required == 'v' )|| ( required == 'V'))
{
printf("enter the lenght and the width");
scanf("%d%d",&l,&w);
printf("the vicinity of the rectangle = %d",(l+w)*2);
}
break;
default:
{
printf("Wrong choice.Try again“);
{
}
getch();
}
السلام عليكم :)
يقول لي البرنامج ان الاخطاء في الأقواس .. !
ما الخطأ جزاكم الله خيراً :)
وهل في احد عندو برنامج بسيط بالـ loop ؟ اقدر امشي على نفس خطواته
شكراً جزيلاً
موفقين