Question

Submit two C++ files: 1. Write a C++ program that declares an array alpha of 50...

Submit two C++ files:

1. Write a C++ program that declares an array alpha of 50 components of type double. Initialize the array so that the first 25 components are equal to the square of the index variable, and the last 25 components are equal to three times the index variable. Output the array so that 10 elements per line are printed.

2. Write a program that prompts the user to input a string and outputs the string in uppercase letters. (Use a character array to store the string.)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>

using namespace std;

int main() {

double alpha[50];

int i;

// FIRST 25 numbers to square of index

for(i=0; i<25; i++)

{

alpha[i] = i*i;

}

// Next 25 numbers to cube of index

for(i=0; i<50; i++)

{

alpha[i] = i*i*i;

}

// printing array

for(i=0; i<50; i++)

{

cout << alpha[i] << " ";

// printing new line after each 10 numbers

if((i+1)%10 == 0)

cout << endl;

}

}

/*SAMPLE OUTPUT

0 1 8 27 64 125 216 343 512 729

1000 1331 1728 2197 2744 3375 4096 4913 5832 6859

8000 9261 10648 12167 13824 15625 17576 19683 21952 24389

27000 29791 32768 35937 39304 42875 46656 50653 54872 59319

64000 68921 74088 79507 85184 91125 97336 103823 110592 117649

*/

#include <iostream>

using namespace std;

int main() {

// taking user input

char word[100];

cout << "Input a string: ";

cin >> word;

// looping through characters

for(int i=0; word[i]; i++)

{

// if it is a lower case letter

if(word[i] >= 'a' && word[i] <= 'z')

// changing it to upper case

word[i] = word[i] - 32;

}

cout << word;

}

/*SAMPLE OUTPUT

Input a string: India

INDIA

*/

Add a comment
Know the answer?
Add Answer to:
Submit two C++ files: 1. Write a C++ program that declares an array alpha of 50...
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
  • Write a C++ program: Declares an array named numberList with 50 components of the type int....

    Write a C++ program: Declares an array named numberList with 50 components of the type int. Initialize the array so that the first 25 components are equal to the square of the counter (or index) variable and the last 25 components are equal to 1, 2, 3, … , 25. Output the array so that exactly ten elements per line are printed.

  • In need this in C language! Write a program that declares a 40 element array of...

    In need this in C language! Write a program that declares a 40 element array of type double. Initialize the array so that: the first 10 elements are equal to the square of the index variable the next 10 each elements is equal to three times the index variable the next 10 each element is equal to the sum of an element in the first 10 + an element in the second 10 the last 10 each element is equal...

  • | ome Insert Design Layout References Mailings View Help Tell me what you want to do from the l U...

    | ome Insert Design Layout References Mailings View Help Tell me what you want to do from the l Unless you need to edit, it's safer to stay in 11. Write C++ statements that do the following: a. Declare an array alpha of 10 rows and 20 columns of type int. b. Initialize the array alpha to 0. c. Store 1 in the first row and 2 in the remaining rows d. Store 5 in the first column, and make...

  • Write a C++ program to get an input string from the user, and output the string...

    Write a C++ program to get an input string from the user, and output the string in uppercase letters. Use a dynamic character array to store the string. ?(this can be from any input file, there is no specific file.)

  • Write code that declares an array of integer values that will represent the first five even...

    Write code that declares an array of integer values that will represent the first five even numbers: 2, 4, 6, 8, 10. Add code to initialize each element of the array with the even number values shown above. Add code to calculate the product of the array elements, and store the result in a variable named product. You must access the array elements to accomplish this. Do not write product = 2 * 4 * 6 * 8 * 10;...

  • Structures in C++ :- 1. Write a program that declares a structure to store the code...

    Structures in C++ :- 1. Write a program that declares a structure to store the code number, salary and grade of an employee. The program defines two structure variables, inputs record of two employees and then displays the record of the employee with more salary. 2. Write a program that declares a structure to store the distance covered by player along with the time taken to cover the distance. The program should input the records of two players and then...

  • Part 2) write a C++ program that declares a 2 dimensional array: int CSIIAssign3 [10][12]; Initialize...

    Part 2) write a C++ program that declares a 2 dimensional array: int CSIIAssign3 [10][12]; Initialize your array using a text file, user input or assign value while declaring the array, you can choose the method. Then, a. Write a loop to print first row of the array on one line, using cout. b. Write a loop to print first column of the array on one line, using cout. c. Write a loop to print first five rows of the...

  • 2. Searching a String: Write a MIPS assembly language program to do the following: Read a...

    2. Searching a String: Write a MIPS assembly language program to do the following: Read a string and store it in memory. Limit the string length to 100 characters. Then, ask the user to enter a character. Search and count the number of occurrences of the character in the string. The search is not case sensitive. Lowercase and uppercase letters should be equal. Then ask the user to enter a string of two characters. Search and count the number of...

  • Structures in C++ :- 2. Write a program that declares a structure to store the distance...

    Structures in C++ :- 2. Write a program that declares a structure to store the distance covered by player along with the time taken to cover the distance. The program should input the records of two players and then display the record of the winner. 3. Write a program that declares a structure to store income, tax rate and tax of a person. The program defines an array of structure to store the records of five person. It inputs income...

  • Please help C++ language Instructions Write a program that prompts the user to enter 50 integers...

    Please help C++ language Instructions Write a program that prompts the user to enter 50 integers and stores them in an array. The program then determines and outputs which numbers in the array are sum of two other array elements. If an array element is the sum of two other array elements, then for this array element, the program should output all such pairs.

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