Question

d printAllIntegers () Write a C++ program that defines and tests a function largest(....) that takes as parame- ters any thre
7.3 Recursive Functions Write a program that uses a function sum(int) that takes as an argument a positive integer n and retu
0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>
using namespace std;

int main() {
   int a, b, c;
   cout<<"Enter three integers: ";
   cin >> a;
   cin >> b;
   cin >> c;
   cout<<"The largest integer is ";
   if (a > b && a > c) {
      cout << a << endl;
   }
   else if (b > c) {
      cout << b << endl;
   }
   else {
      cout << c << endl;
   }
   return 0;
}

////////////////////////////////////////////////////////////////

#include <iostream>
using namespace std;

int main() {
   int n, sum = 0;
   cout<<"Enter a positive integers: ";
   cin >> n;
   
   for (int i = 1; i <= n; i++) {
      sum += i;
   }

   cout << "The sum of first " << n << " positive integers is " << sum << endl;
   return 0;
}
Add a comment
Know the answer?
Add Answer to:
d printAllIntegers () Write a C++ program that defines and tests a function largest(....) that takes...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT