Toshkent axborot texnologiyalari universiteti axborot xavfszligi fakulteti


Download 318.48 Kb.
bet2/2
Sana21.11.2020
Hajmi318.48 Kb.
1   2
2-savol

8-variant



Berilgan n uchun s ning qiymati hisoblansin:

a) s=1! +2!+3! +4!+…+(1)n+1n!;



b) s=-2!+4!+…+(-1)n(2n)!.

  1. #include

  2. #include

  3. using namespace std;

  4. int main ()

  5. {int p=1, a, n, s=1;

  6. cout<<"n="; cin>>n;

  7. for(a=1; a<=n; a++)

  8. p=p*a;

  9. s=s+p;

  10. cout<<"s="<

  11. return 0;

  12. }

3-savol


8-variant

8. Butun sonlar ketma-ketligi kiritiladi, 0 - ketma-ketlikning oxiri. Ketma-ketlikdagi 7 ga karra va 5 ga karra bo’lmagan sonlar sonini va manfiy sonlar yig’indisini aniqlang.

  1. #include

  2. #include

  3. using namespace std;

  4. int main ()

  5. {

  6. int a, b, m, summa=0, n;

  7. cout<<"n="; cin>>n;

  8. cout<<"m="; cin>>m;

  9. for(a=n; a<=m; a++)

  10. if(a%5!=0 and a%7!=0 and a<0)

  11. summa=summa+a;

  12. cout<<"summa="<

  13. return 0;

  14. }


Download 318.48 Kb.

Do'stlaringiz bilan baham:
1   2




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