Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Write a recursive function to find sum of even numbers from 2 to 50 in c language
- int sumEvensRecursively(int no1, int no2)
- {
- no1=5;
- no2=20;
- if (no1 % 2 == 1)
- {
- return sumEvensRecursively(no1+ 1, no2);
- }
- return no1+ sumEvensRecursively(no1+ 2, no2);
- }
- recur(int sum, int i){
- if(i <= 50){
- sum = sum + i;
- return recur(sum, (i+2));
- }
- else
- return sum;
- }
- recur(0,2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement