SHARE
TWEET

Untitled

a guest May 5th, 2012 184 Never
  1. Write a recursive function to find sum of even numbers from 2 to 50 in c language
  2. int sumEvensRecursively(int no1, int no2)
  3. {
  4. no1=5;
  5. no2=20;
  6. if (no1 % 2 == 1)
  7. {
  8. return sumEvensRecursively(no1+ 1, no2);
  9. }
  10.  
  11. return no1+ sumEvensRecursively(no1+ 2, no2);
  12.  
  13. }
  14.        
  15. recur(int sum, int i){
  16.     if(i <= 50){
  17.         sum = sum + i;
  18.         return recur(sum, (i+2));
  19.  
  20.     }
  21.     else
  22.         return sum;
  23.  
  24. }
  25.        
  26. recur(0,2);
RAW Paste Data
Top