Amaliy mashg’ulot Takrorlanish operatorlari


Download 171.77 Kb.
Sana06.01.2023
Hajmi171.77 Kb.
#1080906
Bog'liq
Kudratov Ruslan 0102 amalyot №2


2 – Amaliy mashg’ulot
1 Takrorlanish operatorlari
20 dan 160 gacha bo'lgan juft sonlarning kvadratlari yig'indisini hisoblang.
#include
#include
using namespace std;
int main() {
int i = 20;
int sum = 0, n =160;
for (int i = 20; i <= n; i++)
{ sum += pow(i,2); i++;
}
cout <<" Natija: "<return 0;
}

2 Takrorlanish operatorlari
Musbat va manfiy elementlardan tashkil topgan z = (10; -5; -8; -6; 17; 25; 31; 10; 12; 38), (j = 1,..., 10) massivi berilgan. Massivning musbat elementlari soni va ularning indekslarini chop etish dasturini tuzing.
#include
#include
using namespace std;
int main()
{ int i,a[10]={10,-5,-8,-6,17,25,31,10,12,38};
for (i=0;i<10;i++)
{
if (a[i]>0) {cout< }}}

Download 171.77 Kb.

Do'stlaringiz bilan baham:




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