i dn't have my laptop with me yet.i live in hostel and i came home due to weekend..i hav to submit task tomorrw,,plz if you help me i wud b very thnkful to you
# include<iostream>
# include<conio.h>
using namespace std;
void sum(double& sum,int n){
float add=0;
cout<<"please enter the value of n"<<endl;
cin>>n;
for (int i=1;i<=n; i++){
add +=1.0/i;
}
}
void main(){
double k=0;
int j=0;
sum(k,j);
cout<<"sum is"<<endl;
getch();
this is the program that i want to build..actully i want to sum the series using function void sum(double& sum,int n),the series is 1/1+1/2+1/3...1/n where n is positiv integer
sorry i posted another code,this code is not the one i mentioned..can you please give me the hint that how to calculate the greatest comon divisor of two numbers?
int gcd(int a, int b)
{
if(a == 0) return b;
if(b == 0) return a;
if(a < b)
{
a += b;
b = a - b;
a -= b;
}
int c;
c = a % b;
while(c > 0)
{
a = b;
b = c;
c = a % b;
}
return b;
}
writing the code is not the hard core usually, you need to know how to think about an issue, and express it with programming language. and i did not see any difference as explaining it in natural language.
question is write a function that calculate the greatest common divisor of two number..
oops, this is your question.
what do you mean by common divisor, but not the greatest common divisor?
there could be more then one common divisor between two files.