عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 25-11-2010, 06:12 PM   #913

sil--ver

جامعي

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

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

المشاركة الأصلية كتبت بواسطة NaSeM مشاهدة المشاركة
كود:
#include<stdio.h>
#include<conio.h>
void main ()
{
	char x,y;
	double l=0,w=0,h=0,r=0,s=0;
      printf("Enter:\na for circumference or b for area\n");
	   scanf("%c",&x);
      printf("Enter:\n    s for Square\n or r for rectangle\n or c for Circle\n or t FOR Tringle\n");
	   scanf("%c",&y);

	     switch(x)
    {
		 case 'a':
       {
		    if (y=='s'||y=='S')
          {
				printf("enter l for length\n");
			    scanf("%lf",&l);
				printf("the area of square is equal to ( %f )",l*l);
           }
			else if (y=='r'||y=='R')
          {
				printf("enter w for width and h height for\n ");
			    scanf("%lf %lf",&h,&w);
				printf("the area of Rectangle is equal to ( %f )",w*h);
           }
			else if (y=='c'||y=='C')
           {
				printf("enter r for radius\n ");
				scanf("%lf",&r);
				printf("the area of circle is equal to ( %f )",3.14*r*r);
           }
			else if (y=='t'||y=='T')
          {
				printf("enter h for vertical height and s for base\n ");
				scanf("%lf%lf",&h,&s);
				printf("the area of circle is equal to ( %f )",.5*s*h);
           }
			else
          {
				printf("error choice,try again");
          }
      }
		break;

		 case 'b':
       {
		    if (y=='s'||y=='S')
          {
				printf("enter l for length\n");
			    scanf("%lf",&l);
				printf("the circumference of square is equal to ( %f )",4*l);
           }
			else if (y=='r'||y=='R')
           {
				printf("enter the two sides h and w\n ");
				scanf("%lf %lf",&h,&w);
				printf("the circumference of Rectangle is equal to ( %f )",2*w*2*h);
           }
			else if (y=='c'||y=='C')
           {
				printf("enter r for radius\n ");
				scanf("%lf",&r);
				printf("the circumference of circle is equal to ( %f )",2*3.14*r);
           }
			else if (y=='t'||y=='T')
           {
				printf("enter the three sides h , s and w\n ");
				scanf("%lf%lf%lf",&h,&s,&w);
				printf("the circumference of circle is equal to ( %f )",h+s+w);
            }
			else
            {
				printf("error choice,try again");
            }
        }
	    break;

		 default : printf("error choice,try again");
 	}
getch();
}
إيش الخطأ اللي عندي ؟؟
لمن اسوي رن ادخل الخيار الاول وبعدها لمن اجي ادخل الخيار الثاني يروح على طول عا (defalt ( error choice بدون مايسوي العمليات والمفروض مايروح للـerror choice !!!!!!??

الكود صح بس لام نضع مسافة في " %c"
كود:
#include<stdio.h>
#include<conio.h>
void main ()
{
	char x,y;
	double l=0,w=0,h=0,r=0,s=0;
      printf("Enter:\n a for circumference or b for area\n");
	   scanf(" %c",&x);
      printf("Enter:\n    s for Square\n or r for rectangle\n or c for Circle\n or t FOR Tringle\n");
	   scanf(" %c",&y);

	     switch(x)
    {
		 case 'a':
       {
		    if (y=='s'||y=='S')
          {
				printf("enter l for length\n");
			    scanf("%lf",&l);
				printf("the area of square is equal to ( %f )",l*l);
           }
			else if (y=='r'||y=='R')
          {
				printf("enter w for width and h height for\n ");
			    scanf("%lf %lf",&h,&w);
				printf("the area of Rectangle is equal to ( %f )",w*h);
           }
			else if (y=='c'||y=='C')
           {
				printf("enter r for radius\n ");
				scanf("%lf",&r);
				printf("the area of circle is equal to ( %f )",3.14*r*r);
           }
			else if (y=='t'||y=='T')
          {
				printf("enter h for vertical height and s for base\n ");
				scanf("%lf%lf",&h,&s);
				printf("the area of circle is equal to ( %f )",.5*s*h);
           }
			else
          {
				printf("error choice,try again");
          }
      }
		break;

		 case 'b':
       {
		    if (y=='s'||y=='S')
          {
				printf("enter l for length\n");
			    scanf("%lf",&l);
				printf("the circumference of square is equal to ( %f )",4*l);
           }
			else if (y=='r'||y=='R')
           {
				printf("enter the two sides h and w\n ");
				scanf("%lf %lf",&h,&w);
				printf("the circumference of Rectangle is equal to ( %f )",2*w*2*h);
           }
			else if (y=='c'||y=='C')
           {
				printf("enter r for radius\n ");
				scanf("%lf",&r);
				printf("the circumference of circle is equal to ( %f )",2*3.14*r);
           }
			else if (y=='t'||y=='T')
           {
				printf("enter the three sides h , s and w\n ");
				scanf("%lf%lf%lf",&h,&s,&w);
				printf("the circumference of circle is equal to ( %f )",h+s+w);
            }
			else
            {
				printf("error choice,try again");
            }
        }
	    break;

		 default : printf("error choice,try again");
 	}
getch();
}

 

توقيع sil--ver  

 

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


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


 

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