Programming Basics SQL HTML CSS JavaScript Python C++ Java JavaFX Swing Problem Solving English English Conversations Computer Fundamentals Learn Typing

تحديات برمجيةالتحدي الأول - حل التمرين الخامس بلغة C++

المطلوب

أكتب برنامج يطلب من المستخدم إدخال رقمين, ثم يعرض له ناتج جمعمها, طرحهما, ضربهما و قسمتهما.
مثال: إذا قام المستخدم بإدخال الرقمين 14 و 5 فستكون النتيجة كالتالي.

Enter first number: 14
Enter second number: 5
14 + 5 = 19
14 - 5 = 9
14 * 5 = 70
14 / 5 = 2
	

الحل بلغة C++

#include <iostream>
int main() {
int x, y;
std::cout << "Enter first number: ";
std::cin >> x;
std::cout << "Enter second number: ";
std::cin >> y;
std::cout << x << " + " << y << " = " << x + y << "\n";
std::cout << x << " - " << y << " = " << x - y << "\n";
std::cout << x << " * " << y << " = " << x * y << "\n";
std::cout << x << " / " << y << " = " << x / y << "\n";
char end; std::cin >> end;
return 0;
}
#include <iostream> int main() { int x, y; std::cout << "Enter first number: "; std::cin >> x; std::cout << "Enter second number: "; std::cin >> y; std::cout << x << " + " << y << " = " << x + y << "\n"; std::cout << x << " - " << y << " = " << x - y << "\n"; std::cout << x << " * " << y << " = " << x * y << "\n"; std::cout << x << " / " << y << " = " << x / y << "\n"; char end; std::cin >> end; return 0; }

سنحصل على النتيجة التالية إذا قام المستخدم بإدخال الرقمين 14 و 5 عند التشغيل.

Enter first number: 14
Enter second number: 5
14 + 5 = 19
14 - 5 = 9
14 * 5 = 70
14 / 5 = 2