creat a sum function using recursion
sum=10+9+8+7+6+5+4+3+2+1=55..............
اردو۔۔۔۔۔۔۔۔۔۔۔۔۔۔۔۔۔۔
ایک جمع کا فنکشن بنائیں جس میں ریکریژن استعمال ہو۔۔
creat a sum function using recursion
sum=10+9+8+7+6+5+4+3+2+1=55..............
اردو۔۔۔۔۔۔۔۔۔۔۔۔۔۔۔۔۔۔
ایک جمع کا فنکشن بنائیں جس میں ریکریژن استعمال ہو۔۔
sum ni kar rha .... bahi
- - - Updated - - -
ma ny tuesday ko is ke assignment submit karani ha
This seems your homework, so now for last time I am solving your homework problem but next time solve your homework with your own ability. Yes, I will help you if you are trying to code and stuck at a problem then upload your coding I will try to find errors and then I will tell you that where you are making mistake.
So this is for last time.
Here is coding:
Code:#include<iostream> using namespace std; int n = 0; int Sum(int s) { int result; if( s == n ) return n; else { result = Sum(s+1) + s; return result; } } int main() { cout<<"Enter a number to which you want sum: "; cin>>n; cout<<"The sum of numbers up to "<<n<<" is "<<Sum(1); cin.ignore(); cin.get(); }Screen Shot
thanks .......
Thats the real answer
Bookmarks