السلام عليكم ورحمة الله وبركاته
سؤال اقمت بحله على حسب فهمي اذا كان خطا اتمنى التصحيح
السؤال
write aprogram that asks for an integer and reports whether the number is odd od even
use if ..Else statement
محاولتي
# include <iostream>
using namespace std;
int main (void)
{
int x , y ;
cout << "Enter a number : " ;
cin >> x ;
y=x%2 ;
if (y==0)
{
cout << "The number is even" << endl;
}
if (y==1)
{
cout << "The number is ood" << endl;
}
return 0 ;
}
ولو طلبت بطريقة switch كيف طريقتها؟
وجزاكم الله خير
