Question #262563

Write a C# application that asks the user to input ‘A’ and ‘B’ and prints the sum of squares of all odd numbers between ‘A’ and ‘B’. 


Expert's answer

Using system;
namespace Example1{
class program{
    public static void public static void Main(string[] args)
    {
        int A,B,sum=0;
        Console.WriteLine("Enter the first number:");
        A=Console.ToInt32(readLine());
        Console.WriteLine("Enter the second number:");
        B=Console.ToInt32(readLine());
        for(int i=A;i<=B;i++){
            if(i%2==1){
         sum=sum+pow(i,2);
         }
        }
        Console.WriteLine("sum of squares of all odd numbers between a and b"+)


    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS