0
How to print the sum of factors of given number
3 odpowiedzi
0
sum=a+b
cout <<sum
0
#include <iostream>
using namespace std;
int main()
{
int a, b;
int sum;
cout << "Enter a number \n";
cin >> a;
cout << "Enter another number \n";
cin >> b;
sum = a + b;
cout << "Sum is: " << sum << endl;
return 0;
}
0
This is the program I have written to find its factor n want to find its sum also...
#include <iostream>
using namespace std;
int main()
{
int num,sum=0;
cout<<"\nEnter the number";
cin>>num;
for(int a=1;a<=num;a++)
{
if(num%a==0)
cout<<endl<<a<<endl;
}
return 0;
}