1. Doira diametri d-berilgan. Uning uzunligi L= π*d topilsin. Bu yerda π=3.1415
Yechilishi C++
#include
#include
using namespace std;
int main()
{
float d;
cout<<"d:";
std::cin >> d;
float L=4*3.1415;
cout<< "L." << L;
return 0;
}
|
Konsolga chiqarish:
d:4
L.12.566
...Program finished with exit code 0
Press ENTER to exit console.
|
2. Bitta to’g’ri chiziqda yotuvchi A,B va C nuqtalar berilgan. C-nuqta A va B nuqtalar orasida joylashgan. AC va BC kesmalar uzunliklari kopaytmasi topilsin/
int main()
{
int A,B,C, AC, BC;
cout<< "A=";
std::cin >> A;
cout<< "B=";
std::cin >> B;
cout<< "C=";
std::cin >> C;
AC=abs(C-A);
BC=abs(B-C);
cout<< AC*BC;
|
Konsoldan o’qib olamiz
A=4
B=8
C=6
4
...Program finished with exit code 0
Press ENTER to exit console.
|
3.A, B va C butun sonlari berilgan. Ularning qiymatlarini o’zaro almashtiring.
#include
using namespace std;
int main()
{
int A,B,C,D;
cin>>A>>B>>C;
D=A;
A=B;
B=C;
C=D;
std::cout <std::cout <std::cout < |
Qiymatni kiritamiz:
5 10 9
Javob:
10
9
5
...Program finished with exit code 0
Press ENTER to exit console.
|
4.
Yechilishi C++
#include
#include
using namespace std;
int main()
{
int a,b,s=0;
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
for(int i=a;i<=b;i++){
for(int j=1;j<=i;j++){
cout<}
cout<}
cout<<"\nyigindi="<return 0;
}
|
Javobi:
a=3
b=6
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
yigindi=0
...Program finished with exit code 0
Press ENTER to exit console.
|
5.
Yechilishi C++
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
int A, B;
cout << "A=";
cin >> A;
cout << "B=";
cin >> B;
for (int i = B - 1; i >= A; i--)
{
cout << i << " ";
}
return 0;
}
|
Javobi:
A=4
B=7
6 5 4
...Program finished with exit code 0
Press ENTER to exit console.
|
Do'stlaringiz bilan baham: |