foundationda 4 – dars

foundationda 4 - dars


bu kodda x va y ga qiymat bera olamiz

int main (){
// assigment operator
int x = 5;
int y = x;// y = 5
y = x + 5;// y = 10
}

bu kod besh honali sonni ortasidagi ya’ni 12345 sonnning 3 chisini chiqazib beradi.

int main(){
int son = 12345;
cout << son % 10 << endl;
cout << son / 10 % 10 << endl;
cout << son / 100 % 10 << endl;
cout << son / 1000 % 10 << endl;
cout << son / 10000 % 10 << endl;
}
Birinchi ikkita satr kiritish/chiqarish operatsiyalari ( ) va chiqishning aniqligini o’rnatish ( ) uchun kerakli sarlavha fayllarini o’z ichiga oladi .
Chiziq dasturga va ob’ektlarini o’z ichiga olgan nomlar maydonidan using namespace std;foydalanishga imkon beradi .stdcoutcin
Funktsiyada main()ikkita doubleo’zgaruvchi widthva lengthto’rtburchakning o’lchamlarini saqlash uchun e’lon qilinadi.
Dastur cinfoydalanuvchining qiymatlarini widthva lengthfoydalanuvchidan o’qish uchun foydalanadi.
To’rtburchakning maydoni ko’paytirish yo’li bilan hisoblanadi widthva lengtho’zgaruvchida saqlanadi area.
coutNatijani ko’rsatish uchun bayonot ishlatiladi . fixedva manipulyatorlari setprecision(2)chiqish formatini ikki kasrli sobit nuqtali yozuvga o’rnatish uchun ishlatiladi.
Dastur “Maydon” xabarini, keyin hisoblangan maydon va nuqtani chop etadi.
Bayonot return 0;dasturning muvaffaqiyatli bajarilishini ko’rsatadi.

include

include

using namespace std;
int main(){
double width, length;

cin >> width >> length;

double area = width * length;

cout << fixed << setprecision(2);

cout << “Area is ” << area << “.” << endl;

return 0;

}



Source link
lol

By stp2y

Leave a Reply

Your email address will not be published. Required fields are marked *

No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.