الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

مشكلة في هووم وورك ++C

مغلق
بدأه princess-amorah في 18 نوفمبر 2005 · 2 رد · 503 مشاهدة · في ارشيف قسم C/C++
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

مرحبا

الاستازة طالبه مننا نعمل برنامج ندخل ل 3 اشخاص رواتب وبعدين ع حسب كل راتب نعملووو خصم اممممم فهمتو

:unsure: :unsure: :unsure:

اوكى المشكله الي بتجيني

error C2181: illegal else without matching if

#include<stdio.h>

int main()

{

int num=3000;

int money;

int a,b,d;

int opposing;

printf("person a:");

scanf("%d",&money);

printf("person b:");

scanf("%d",&money);

printf("person d:");

scanf("%d",&money);

if(money>=num)

opposing=(money*10)/100;

printf("money opposing:%d",opposing);

else opposing=(money*5)/100;

printf("money opposing:%d",opposing);

return 0;

}

تم تعديل هذه المشاركة بواسطة princess-amorah في 18 نوفمبر 2005 في 11:20

#2

تصحيح الخطأ

#include<stdio.h>
int main()
{
int num=3000;
int money;
int a,b,d;
int opposing;

printf("person a:");
scanf("%d",&money);
printf("person b:");
scanf("%d",&money);
printf("person d:");
scanf("%d",&money);


if(money>=num)
{
 opposing=(money*10)/100;
printf("money opposing:%d",opposing);
}


else
{
 opposing=(money*5)/100;
printf("money opposing:%d",opposing);
}

return 0;
}

لاحظ أن جملة الif تنفذ على سطر واحد فقط كما ف المثال التالى

if(money == num)
//print hello

أما لو كان أكتر من سطر كما ف المشكلة السابقة تضع أقواس كما يلى

if(money>=num)
{
 opposing=(money*10)/100;
printf("money opposing:%d",opposing);
}

Muhammad Allam

Computer Science

@Resource(MappedURL="My Blog" )

#3

:D :D :D

كتييييييييييييييييييييييير شكراً

وبجد نفعت معاهاااا

:lol: :lol: :lol:

هذا الموضوع مغلق.

مواضيع مشابهة