How does this C++ code return 0,0,3 | بلاگ

How does this C++ code return 0,0,3

تعرفه تبلیغات در سایت

آخرین مطالب

امکانات وب

Vote count: 0

Here is the code :

#include
using namespace std;
int a, b;
int f(int c)
{
    int n = 1;
    for (int i = 0; i < c, i++;)
    {
        int a = n + i;                              
    }                                     
    return a;
}
void main()
{
    int i = 3;
    int b = f(i);          
    cout << a << b << i;
}

The output is 0,0,3

I understand the a = 0 because it is a global variable and defaults to 0, and i = 3, but I can't figure out how or why b = 0

asked 1 min ago
samh30

...
نویسنده : استخدام کار بازدید : 8 تاريخ : سه شنبه 29 اسفند 1396 ساعت: 8:52