Computer Science, asked by krishnak6095, 4 months ago

Vrite a program to find the sum of the 1st 10 odd natural numbers.​


atrs7391: Language
atrs7391: Programming language
krishnak6095: for loop
atrs7391: I mean python, java, qbasic
atrs7391: what
krishnak6095: java
atrs7391: ok wait
krishnak6095: please send me

Answers

Answered by ashparikh1974
0

Answer:

hsbdbcbfbsh KGB 4bdbrnsj ed jd djdn end hdhea

Answered by atrs7391
0

Here is your answer:

package com.company;

public class Main {

   public static void main(String[] args) {

       int sum = 0;

       for (int j = 0; j < 20; j++) {

           if (j%2==1){

               //System.out.println(j);

               //You can add the above line if you want to display the odd numbers too.

               int sum2 = j;

               sum2 = sum2+j;

               sum = sum2;

           }

       }

       System.out.println("The sum of first 10 odd natural numbers are: "+sum);

   }

}

Attachments:
Similar questions