Program that return the sum of square of all odd numbers of inputted number.

class SumOfSqure

 {
   public static void main(String args[])
   {
    int sum=0;
    int arr[]={10,12,11,13,15};
    for(int i=1;i<=4;i++)
   {
       if(arr[i]%2==1)
    {
      int a=arr[i]*arr[i];
      sum=sum+a;
     }
    }
   System.out.println("sum of squre of odd no="+sum);
  }
}

No comments:

Post a Comment