A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

C program to find the sum of even numbers between 50 to 100?

Best Answers

The even numbers between 50 to 100 will be in A.P. with a difference of 2 .So you can apply sum of A.P. formula . The below approach will solve the problem in constant time. #include <iostream>. using namespace std;. int main() {. int a,l;. cin>>a>>l;. a=a+2;. l=l-2;. int d=2;. int n=((l-a)/d)+1;. int s=(n/2)*(a+l);. cout<<s<<"\n";. read more

Yes. I suppose I should expand on that. Yes, I just wrote such a program. I had to make an assumption about what you meant by “between 50 to 100”; my assumption is that both 50 and 100 are included in the range of numbers to be added. read more

Case 1: Enter the value of num 10 Sum of all odd numbers = 25 Sum of all even numbers = 30 Case 2: Enter the value of num 100 Sum of all odd numbers = 2500 Sum of all even numbers = 2550 Sanfoundry Global Education & Learning Series – 1000 C Programs. read more

Write a C program to input number from user and find sum of all even numbers between 1 to n. Logic to find sum of all even numbers in a given range in C. read more

Encyclopedia Research

Wikipedia:

Related Facts

Related Types

Image Answers

Further Research