We have a 4 x 4 two dimensional array. Fill it with random values from 1 to 100. Write a code to take transpose of the matrix. The following array is shown as an example:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
BECOMES
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
Create an array of size 5x5 first fill the array with random values between 1 and 100, print it in straight and reverse order. Then fill that array from the user, print it in straight and reverse order.
Create an array of size 10 fill the array from the user. Then ask the user for the order of sorting ascending or descending. And sort the array using bubble sorting algorithm.
Write a program that declares 2 integer arrays x, y of size 10 each. The program then reads values for x and y arrays from the user (use some common values).
Finally the program finds the common values in x and y and prints them. If there is no common values in x and y print “There is nothing common between array x and y”.
Your boss sent you a notepad file called numbers.txt containing an
unknown number of integers. He requests you to write a single program
that a) reads these numbers into an array b) checks whether the file
has correctly opened c) prints out the average of all the numbers in the
array d) then program should search the array to see whether integer 150
is present e) finally the program should print out all the positive numbers
in the array. [20]
Create a class called Cuboid with the data members: length (float), breadth (float) and height (float). Use an inline function and calculate the area of the base using the formula = length * breadth and print it.
Define another member function and calculate the total surface area of the cube using the formula = 2*(length*breadth + breadth*height + height*length) and print it.
Define a friend function to calculate the volume of the cuboid using the formula = length*breadth*height. After calculating the volume, calculate the amount of liquid that can be stored if 1𝑚3 can store 100 liters of liquid.
Write a program to:
a) Initialize an array of 8 entries for serial number.
b) Set the value of 5th serial number to 89.
c) Set the value of 3rd serial number to the addition of first two serial numbers.
d) Display the serial number on 2nd index
e) Print the whole array
Write a program that dynamically allocates an array large enough to hold a user-defined number of test
scores. Once all the scores are entered, the array should be passed to a function that sorts them in
ascending order. Another function should be called that calculates the average score. The program
should display the sorted list of scores and averages with appropriate headings. Use pointer notation
rather than array notation whenever possible.
Input Validation: Do not accept negative numbers for test scores.
Example
Enter the number of test scores: 4
Enter each test score:
Test#1: 34
Test #2: 73
Test #3: 22
Test #4: 89
Sorted test scores:
Test #1: 22
Test #2: 34
Test #3: 73
Test #4: 89
Average = 54.5
Find the errors
int sum(int x, int y)
{
int result; result = x + y;
}
An integer is said to be a perfect number if the sum of its divisors, including 1 (but not the number itself),
is equal to the number. For example, 6 is a perfect number, because 6 = 1 + 2 + 3. Write a function
isPerfect() that determines whether parameter number is a perfect number. Use this function in a
program that determines and prints all the perfect numbers between 1 and 1000. Print the divisors of
each perfect number to confirm that the number is indeed perfect. Challenge the power of your computer
by testing numbers much larger than 1000.