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. }
Do'stlaringiz bilan baham: |