Share all news to all guy ;)

Monday, December 22, 2014


             Write a program that asks the user to type 10 integers and writes the sum of these integers. Using for loop. Total sum of ten integer ( 1+2+3+4+5+6+7+8+9+10=55) .

Code here :

 public static void main(String[] args) {
        int sum=0;
       for(int i=1 ; i<=10 ; i++){
            System.out.print(i + " + ");
            sum = sum +i;
       }
       System.out.print("\b\b\b");
       System.out.println(" = " + sum);
    }
    

}


0 comments:

Post a Comment

Popular Posts

Powered by Blogger.