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’.
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"+)
}
}
Comments
Leave a comment