online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ #include <iostream> using namespace std; /* * دالة لحساب مجموع مضاعفات عدد ما * num => هو العدد المطلوب حساب مضاعفاته * limit => هو الحد الأعلى */ int sumOfMultiples(int num, int limit) { int sum = 0; for (int i = 1; i <= limit ; ++i) { // حلقة فور من 1 إلى الحد الأعلى if (i % num == 0) // إذا كان العدد الحالي يقبل القسم على العدد المطلوب sum += i; // إضافة العدد إلى المجموع } return sum; // إرجاع قيمة المجموع } /* * دالة لحساب عدد مضاعفات عدد ما * num => هو العدد المطلوب حساب عدد مضاعفاته * limit => هو الحد الأعلى */ int countOfMultiples(int num, int limit) { int count = 0; for (int i = 1; i <= limit ; ++i) { if (i % num == 0) // إذا كان العدد الحالي يقبل القسم على العدد المطلوب count++; // نضيف 1 إلى عدد المضاعفات } return count; } /* * دالة لحساب معدل مضاعفات عدد ما * num => هو العدد المطلوب حساب معدل مضاعفاته * limit => هو الحد الأعلى */ float avgOfMultiples(int num, int limit) { return (float) sumOfMultiples(num, limit) / countOfMultiples(num, limit); } int main() { cout << "Sum of multiples of 3 <= 100: " << sumOfMultiples(3,100); // إستعمال العدد 3 و الحد الأعلى 100 cout << "\nCount of multiples of 3 <= 100: " << countOfMultiples(3,100); cout << "\nAvg of multiples of 3 <= 100: " << avgOfMultiples(3,100); return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue