How to print the sum of factors of given number | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to print the sum of factors of given number

19th Aug 2017, 6:53 PM
Aryan Kaushik
Aryan Kaushik - avatar
3 Answers
0
sum=a+b cout <<sum
19th Aug 2017, 7:20 PM
My New World
My New World - avatar
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; }
19th Aug 2017, 7:21 PM
My New World
My New World - avatar
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; }
19th Aug 2017, 7:49 PM
Aryan Kaushik
Aryan Kaushik - avatar