Program to input two integer numbers and display the sum of even numbers between these two input numbers.

Problem Analysis:

The problem is to input the two integers from the user and displays the sum of even numbers between them.For this we need two input variables(a,b) ,a calculation parameter (sum) and another variables(i) for the loop.

 


Input variables          Processing variables        Output variables             Necessary header files


a(int)                            sum=sum+i;                     sum(int)                                conio.h

b(int)                                                                                                                  stdio.h

i(int)

sum(int)=0


 

Algorithms:

1.start

2.Define a,b,i,sum=0

3.Input a,b from the user.

4.Calculation

if (a>b)

for(i=b;i<=a;i++)

if(i%2==0)

sum=sum+i;

if(b>a)

for(i=a; i<=b; i++)

if(i%2==0)

sum=sum+i;

5.Print sum

6.Stop.

 

Codes:

 

outputs:

Compiling , Debugging and testings.

Enter any two numbers:   2    8

20

About Programmingfaster

We the teams of programming faster managed to provide an effective information about the codes of different programming languages.Hope you will learn and understand the codes fast and easy. It's absolutely free, expanding and precise. Our main target is to help those new starters and aid them as far as possible to pave their future in the area of programming. Hoping support and recommendations!
This entry was posted in C, precise examples and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *