0

how can i add the last value to the current value using loop..?
i tried so much but didn't find the answer :(

void main(void)
{
int numbers,add,sec;
clrscr ();
for (numbers=1;numbers<=49;numbers++)
	{
	for (sec=numbers;sec<=numbers;sec=numbers+sec)
	printf ("%d ",sec);
	}
getch();
}

here the loop is from 1 to 50, i want the output as like this,
1,3,6,10,15 and so on...

example:
(current number + the number before current number)

1,
2+1=3,
3+3=6,
4+6=10,
5+10=15
6+15=21
7+21=28

Edited by Xufyan: n/a

1
Contributor
1
Reply
3
Views
6 Years
Discussion Span
Last Post by Xufyan
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.