Reja: Javada operatorlari haqida ma'lumot


class Test{ public


Download 22.41 Kb.
bet4/4
Sana27.01.2023
Hajmi22.41 Kb.
#1130924
1   2   3   4
Bog'liq
while

class Test{


  • public static void main(String[] args){


  • int d=10;


  • while (d<10){


  • System.out.println(d);


  • d++;


  • }


  • }


  • }

    Bu misolda sikl umuman ishlamaydi, chunki (10<10) shart yolg‘on (10=10 bo‘lsa, rost bo‘lar edi) va dastur hech qanday amal bajarmaydi.
    1. SUM(i*i) tuzuvchi dastur tuzilsin.
    1. import java.util.Scanner;
    2. import java.lang.Math;
    public class Main
    3. {
    4. public static void main(String[] args){
    5. Scanner kiritish new = Scanner(System.in);
    6. int n, i=0;
    7. double S=0;
    8. System.out.print(" n= ");
    9. n = kiritish.nextInt();
    10. while(i<=n) {
    11. S+=(i*i);
    12. i++;
    13. }
    14. System.out.print("S = "+S);
    15. main(args);
    16. }
    17. }
    Download 22.41 Kb.

    Do'stlaringiz bilan baham:
  • 1   2   3   4




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