Write a C++ program to calculate the value of y = x2 for all values of x where x = 1, 2, 3, 4, 5. Use nested FOR statement to calculate and display the results as shown on the table below. Compile and run the program then submit the CPP file.
|
x |
y^2 |
a^3 |
a^4 |
a^5 |
|
1 |
1 |
1 |
1 |
1 |
|
2 |
4 |
8 |
16 |
32 |
|
3 |
9 |
27 |
81 |
243 |
|
4 |
16 |
64 |
256 |
1024 |
|
5 |
25 |
125 |
625 |
3125 |
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
cout<<"x\t\ty^2\t\ta^3\t\ta^4\t\ta^5"<<endl;
for(int i = 1; i <= 5; i++)
{
for(int j = 1; j<=5; j++)
{
cout<<pow(i,j)<<"\t\t";
}
cout<<endl;
}
}
==========================
//output
x y^2 a^3 a^4 a^5
1 1 1 1 1
2 4 8 16 32
3 9 27 81 243
4 16 64 256 1024
5 25 125 625 3125
//screen shot

Write a C++ program to calculate the value of y = x2 for all values of...
C++ program Write a program which: 1. Enters data into the 2D array of integers which is 5x5 The data should be entered with an assignment statement using nested for loops that is do not scan in the data. The data should be: 1 2 4 8 16 1 3 9 27 81 1 4 16 64 256 1 5 25 125 625 1 6 36 216 1296 2. Print out the following using a nested for loop Row 0:...
write a program in java to print all the powers of 2 below a certain number and calculate their sum. Make sure your program conforms to the following requirements. 1. Accept the upper limit from the user (as an integer). 2. These numbers grow very fast. make sure the sum variable is of the "long" type. You can assume that the test output will be less that LONG MAX. 3.Print all numbers as a running sum, and finally print their...
Write a C or C++ program
A6pc(pp) that accepts one command
line argument which is an integer n between 2 and 6
inclusive. Generate a string of 60 random upper case English
characters and store them somewhere (e.g. in a char array). Use
pthread to create n threads to convert the string into a
complementary string (‘A’<->’Z’, ‘B’<->’Y’,
‘C’<->’X’, etc). You should divide this conversion task among
the n threads as evenly as possible. Print out the string
both before...
Write a C program to print the figure as follows.
5, Write a C program to print the figure as follows. 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 4 6 8 10 12 14 16 18 9 12 15 18 21 24 27 16 20 24 28 32 36 25 30 35 40 45 36 42 48 54 49 56 63 64 72 81 1 Tip: use loop.
Write a C++ program that will calculate average of squares up to n. For example, if user enters 3 the function should display 1 + 4 + 9/ 3 = 4.6667. Requirements Created function to receive 1 parameter and no return parameter. Called the new function from main function inside a while loop. Calculated the sum of squares and average correctly in the new function using loop with no library functions. Sample Output ~~Enter a number ONLY between 1 and...
In this assignment, you will write a program in C++ which uses files and nested loops to create a file from the quiz grades entered by the user, then reads the grades from the file and calculates each student’s average grade and the average quiz grade for the class. Each student takes 6 quizzes (unknown number of students). Use a nested loop to write each student’s quiz grades to a file. Then read the data from the file in order...
Write a program in C that stores the result of all
multiplications between 1 and 9 in a two-dimensional int array and
then prints the contents of the array to the screen. Also, write
some comments in the code.
Example:
Expected output: 1 4 6 7 8 8 1 12 14 16 18 4 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 1e 15 20 25 30 35 40...
QUESTION 12 Write a program that would prompt the user to enter an integer. The program then would displays a table of squares and cubes from 1 to the value entered by the user. The program should prompt the user to continue if they wish. Name your class NumberPowers.java, add header and sample output as block comments and uploaded it to this link. Use these formulas for calculating squares and cubes are: square = x * x cube = x...
To write a C++ program to find average of three integers using
functions
Objectives: To get familiar with functions in C++ Task 1: Study the working of user-defined functions in C++ Task 2: To write a C++ program to find average of three integers using functions Programming Instructions: Make new project (Visual C++ Empty Project) named lab6 and add a C++ file named lab6.cpp to this project. (Some IDE may automatically generate main.cpp or source.cpp, then you just rename it...
Write a java program to print all the powers of 2 below a certain number and calculate their sum Requirements: 1. Accept the upper limit from the user as an integer 2. Make sure the sum variable is of the “long” type. You can assume that the test output will be less than LONG MAX. 3. Print all the numbers as a running sum, and finally print their sum. Please try and restrict yourself to loops, selection statements, and calls...