Please answer # 4 , I am using Codelite . Thanks Write a program to generate and
ID: 3792215 • Letter: P
Question
Please answer # 4 , I am using Codelite . Thanks
Write a program to generate and display a table of n and n^2, for integer values of n ranging from 1 to 10. Include appropriate column headings. Make sure the table and headings are formatted into two well-aligned columns. Write a program that uses two for loops. The first for loop prints the odd numbers from 1 to 13. The second for loop prints the even numbers from 2 to 16. Write a program that asks the user to enter four digits (separated by spaces) and then prints those digits in English. For example Enter three digits: 1 2 3 4 You entered digits: one two three four Your program should use a switch structure inside a for loop. The factorial of a positive integer n is the product of all integers from 1 to n. For example: 6! = 1 middot 2 middot 3 middot 4 middot 5 middot 6 Write a program that uses nested for loops to generate a table of the first 10 positive integers and their factorials. Include appropriate column headings. Make sure the table and headings are formatted into two well-aligned columns.Explanation / Answer
#include <iostream>
#include<iomanip>
using namespace std;
int main()
{
int f = 1;
int c=1;
cout << "------------------ |NUMBER|FACTORIAL| ------------------" << endl;
for(int i=1;i<11;i++)
{
f=1;
c=1;
while(c<=i)
{
f*=c;
c++;
}
cout << "|"<<setw(5)<<i<<"|"<<setw(7)<<f<<" | ------------------" << endl;
}
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.