#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n = 20, t;
cout << "How many numbers you want to input > ";
cin >> n;
vector<int> arr(n);
cout << "Enter " << n << " number\n";
for(int i=0; i<n; cin >> arr[i++]);
sort(arr.begin(), arr.end());
for(int i=0; i<n; cout << arr[i++] << " ");
cout << endl;
cout << "Enter new two numbers\n";
cin >> t;
arr.push_back(t);
cin >> t;
arr.push_back(t);
sort(arr.begin(), arr.end());
for(size_t i=0; i<arr.size(); cout << arr[i++] << " ");
cout << endl;
}
Comments
Write a program that will display all numbers multiple of 7 which are between 1 and 100 and o display the cumulative sum as well as the final sum
Dear Zahra, Questions in this section are answered for free. We can't fulfill them all and there is no guarantee of answering certain question but we are doing our best. And if answer is published it means it was attentively checked by experts. You can try it yourself by publishing your question. Although if you have serious assignment that requires large amount of work and hence cannot be done for free you can submit it as assignment and our experts will surely assist you.
Write a program that asks the user to enter an array of random numbers,then sort the numbers (ascending order),then print the new array,after that asks the user for a new two numbers and add them to the same array and keep the array organization. solve with do-while
Write a program that will find the inverse of any two dimensional array without the usage of the built-in function. solve with do_while
Write a program that asks the user to enter integer numbers and store the numbers in a two dimensional array,then replace any 9 digit by 0 digit. After that replace the numbers with the odd summations indices by the even summation indices.solve while loop
Write a code that will calculate randomly a number between 1 and 10 (without displaying it) and will ask the user to guess it.If the user answers correctly,the program prints“Good”and add 1 to his score, if not,the program prints“sorry”,gives the correct answer, then selects another number.After 10 consecutive games, the programs stops and prints the final score. Hint: use a random builtin function (rand) and write the #include at the beginning.
Leave a comment