I am new to programming and trying to take a flowchart into pseudo code then into a simple module based off that pseudo code. The module needs to accept parameter and return a value.
This is the pseudo code (I'm not even sure I have that formatted correctly)
1. sum = 0
2. count = 1
3. REPEAT
4. IF count is even THEN sum = sum + Count
5. count = count + 1
6. UNITIL count > 20
7. DISPLAY sum
I can send the flowchart that I think is correct, too.
Does this make sense at all? I'm trying, but I'm not sure I know what the heck I'm doing. Thanks for your help.
#include<iostream.h>
#include<conio.h>
void main()
{
int total,sum(int);
clrscr();
total=sum(2);
cout<<"Sum Of All Even Numbers From 0 To 20 : "<<total;
getch();
}
int sum(int i)
{
static int even=0;
if(i<=20)
{
even=even+i;
sum(i+2);
}
return even;
}