Question

write a c++ program: User enter in 5 numbers, stores  them in an array then displays them...

write a c++ program:

User enter in 5 numbers, stores  them in an array then displays them from least -> greatest.

Then create a char array the user will enter some letters, it gives a count on every 'a' then it gets replaced by an uppercase 'A'. Display the result. Then display only the last letter.

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

Program :

#include <iostream>
#include<climits>
#include<string>
using namespace std;
int main()
{
int a[100],i,j,temp,l;
char ch[100];
cout<<"Enter 5 values:"<<endl;
for(i=0;i<5;i++)
{
cin>>a[i];
}
for(i = 0; i < 5; i++)
{
for(j = 0; j < 5-i-1; j++)
{
if( a[j] > a[j+1])
{
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
cout<<"Least to greatest"<<endl;
for(i=0;i<5;i++)
cout<<a[i]<<" ";

cout<<"\nEnter some letters"<<endl;
cin>>ch;
l=0;
while(ch[l]!='\0')
{
l++;
}
for(i=0;i<l;i++)
{
if(ch[i]=='a')
ch[i]='A';
}
cout<<"\nResult:"<<ch;
cout<<"\nLast letter is:"<<ch[l-1];
return 0;
}

Screenshot of the program :

Output:

output 2:

Add a comment
Know the answer?
Add Answer to:
write a c++ program: User enter in 5 numbers, stores  them in an array then displays them...
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 test program that prompt the user to enter seven numbers, stores them in an...

    Write a test program that prompt the user to enter seven numbers, stores them in an array list and do the following: 1. Displays its elements (numbers) in increasing order by invoking a method with the following header that sorts the array: public static void sort(ArrayList<Integer>list) 2. Write a method that returns and displays the sum of all numbers (elements) of the ArrayList. Using the following header: public static double sum(ArrayList<Integer>list) 3. Write a method that removes the duplicate numbers...

  • // Program takes 5 numbers from a user (from console), stores them into an // array,...

    // Program takes 5 numbers from a user (from console), stores them into an // array, and then prints them to the screen (on the same line). // Add code to complete this program. You only need to add code where indicated // by "ADD HERE". #include <iostream> using namespace std; int main() { const int SIZE = 5; // size of array // ADD HERE - create an array of integers that will hold 5 integers. cout << "please...

  • Python: Write a program that lets the user enter a string and displays the letter that...

    Python: Write a program that lets the user enter a string and displays the letter that appears most frequently in the string, ignore spaces, punctuation, and Upper vs Lower case. Create a list to hold letters based on the length of the user input Convert all letters to the same case Use a loop to check for each letter in the alphabet Have a variable to hold the largest number of times a letter appears, and replace the value when...

  • Write a complete program that: 1. Promts the user to enter 10 numbers. 2. saves those...

    Write a complete program that: 1. Promts the user to enter 10 numbers. 2. saves those numbers in a 32 bit integer array. 3. Calculates the sum of the numbers and displays it. 4. Calcualtes the mean of the array and displays it. 5. Prints the array with the same order it was enterd. 6. Rotates the members in the array forward one position for 9 times. so the last rotation will display the array in reversed order. Print the...

  • Write a C program that asks the user to enter two real numbers. Then your program...

    Write a C program that asks the user to enter two real numbers. Then your program displays a menu that asks the user to choose what arithmetic operation to be done on those numbers. Depending on the user's entry, the program should display the result to the screen. The sample runs below show what should be done to the numbers entered by the user. Your program should run exactly like shown in the sample runs. make your code run as...

  • Write pseudocode in python for a program that prompts a user for 12 numbers and stores...

    Write pseudocode in python for a program that prompts a user for 12 numbers and stores them in an array. Pass the array to a method that reverses the order of the numbers.

  • u also need to store the letters' ASCII number in the freq array 4. [8] Write...

    u also need to store the letters' ASCII number in the freq array 4. [8] Write a C function with prototype · void letter_freq(const char word[], int freq []); This function computes the number of appearances of each letter in the string word and stores them in array freq of size 26. The letters are the 26 letters of the Latin alphabet whose ASCII values are in the range 97-122 for the lower case letters, and in the range 65-90...

  • Write a C++ program that generates an array filled up with random positive integer number ranging...

    Write a C++ program that generates an array filled up with random positive integer number ranging from 15 to 20, and display it on the screen. After the creation and displaying of the array , the program displays the following: [P]osition [R]everse, [A]verage, [S]earch, [Q]uit Please select an option: Then, if the user selects: -P (lowercase or uppercase): the program displays the array elements position and value pairs for all member elements of the array. -R (lowercase or uppercase): the...

  • in C++ please ELET 2300 Programming Assignment # 2 Write a program that generates an array...

    in C++ please ELET 2300 Programming Assignment # 2 Write a program that generates an array filled up with random positive integer number ranging from 15 to 20, and display it on the screen. After the creation and displaying of the array, the program displays the following: [P]osition [Reverse, [A]verage, (Search, [Q]uit Please select an option: Then, if the user selects: -P (lowercase or uppercase): the program displays the array elements position and value pairs for all member elements of...

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