Quyidagi dasturda n soniga jurnaldagi raqamiz kiritilsa dastur natijasini chop eting


Download 21.38 Kb.
Sana20.06.2023
Hajmi21.38 Kb.
#1634592
Bog'liq
1-amaliy ish


  1. Quyidagi dasturda n soniga jurnaldagi raqamiz kiritilsa dastur natijasini chop eting

#include


using namespace std;


int get(int n){


return n < 2 ? n : get(n-1) + get(n-2);


}


int main(){

int n;

cin >> n;

cout << get(n);


return 0;


}


  1. Ushbu dasturni bajarish jarayonida qanday natija ko'rsatiladi.

#include


using namespace std;
int a[5] = {1,2,3,4,5};
class A{
public:
int display()
{
int s = 0;
for (int i=0; i<5; i++)
s+=a[i];
return s;
}
int summa(int n)
{
int S = 0;
for (int i=1; i<=n; i++)
S+=i;
return S;
}
};
class B:public A{
public:
void result()
{
cout << "Result: " << display() << endl;
cout << " Result: " << summa(100) << endl;
}
};
int main()
{
B x;
x.result();
}


  1. Ushbu dastur qismini bajarish jarayonida qanday natija ko'rsatiladi.

class A{

private:

int a = 25;


int minus()


{


return a -10;

}


public:

void display()


{


cout << minus();

}


};

class B:public A{


public:
};


int main()

{
B x;


x.display();


}
Download 21.38 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling