عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 26-11-2010, 01:39 AM   #920

sil--ver

جامعي

الصورة الرمزية sil--ver

 
تاريخ التسجيل: Jul 2009
التخصص: IT ^.^
نوع الدراسة: إنتظام
المستوى: السادس
الجنس: ذكر
المشاركات: 137
افتراضي رد: [cpcs 202 - برمجة 1] لديك سؤال , شيء غير مفهوم ,,, تفضل هنا , موضوع مفيد

المشاركة الأصلية كتبت بواسطة رحاب 09 مشاهدة المشاركة
كود:
#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 ؟ اقدر امشي على نفس خطواته

شكراً جزيلاً


موفقين
أتمنى يكون صحيح

تفضلي
كود:
#include <stdio.h>
#include <math.h>
int main ()
{
char shape,required  ;
int h, x , y , radius , l , w ,b;
 printf("traingle\ncircle\nrectangle\n");
 printf("enter your choic");
 scanf(" %c",&shape);

 printf("area\nvicinity\n");
 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 =  %f ",(0.5*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 = %f",((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 = %f",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");
  }
 }
   return(0);
  }

 

توقيع sil--ver  

 

بسم الله الرحمن الرحيم


رأيت العلم صاحبه كريمٌ......ولو ولدته آباءُ لئِـامُ
وليس يزال يرفعه إلى أن......يُعظم أمره القوم الكرامُ
ويتبعونه في كل حالٍ......كراعي الضأن تتبعه السوام
فلولا العلم ماسعدت رجال......ولاعُرِف الحلال ولا الحرامُ


 

sil--ver غير متواجد حالياً   رد مع اقتباس