LAB , : Armel\" Objective To understand the syntax and the semantic of functions
ID: 3708302 • Letter: L
Question
LAB , : Armel" Objective To understand the syntax and the semantic of functions and arrays in Cr language EXERCISE Write a program that asks the user to type 10 integers of an array and an integer value V and an index value i between 0 and The program must put the value V at the place i in the array,shifting each element right and dropping off the last element.T program must then write the final array EXERCISE 2 Write a program that asks the user to type 10 integers of an array, The program will then diplay either "the array is growing the array is decreasing" or "no order in this array Report writing guidelines Your report must contain the following sections I. Report cover. Please propose a report cover. (S marks Brief Introduction of the experiment (less than 4 Iines) Use your own words to describe the motivations/objectives of the current lab. [10 marks 3. Exercises: Take snapshots of Windows where you wrote programs and comments Windows opened after unning programs Describe your observations for each Program s. IEx 1: 40 markal IEx. 2:40 marks 6 Conclusions Conclude your lab report with a brief summury less than 4 lines) on inowindge and sils that you have scquired fro S marks)Explanation / Answer
#include<iostream>
using namespace std;
int main(){
int data[10];
int i,n,pos;
cout << "Enter 10 numbers: ";
for (i = 0; i<10; i++)
cin >> data[i];
cout << "The given array: ";
for (i = 0; i<10; i++)
cout << data[i] << " ";
cout << endl;
cout << "Enter a number and position: ";
cin >> n >> pos;
for (i = 9; i > pos; i--)
data[i] =data[i-1];
data[pos] = n;
cout << "The final array: ";
for (i = 0; i<10; i++)
cout << data[i] << " ";
cout << endl;
return 0;
}
#include<iostream>
using namespace std;
int main(){
int data[10];
int i,n,pos;
cout << "Enter 10 numbers: ";
for (i = 0; i<10; i++)
cin >> data[i];
cout << "The given array: ";
for (i = 0; i<10; i++)
cout << data[i] << " ";
cout << endl;
int decreasing = 1;
for (i = 0; i<9; i++){
if (data[i] < data[i+1]){
decreasing = 0;
break;
}
}
int increasing = 1;
for (i = 0; i<9; i++){
if (data[i] > data[i+1]){
increasing = 0;
break;
}
}
if (decreasing == 1){
cout << "The array is decreasing ";
}
else if (increasing == 1){
cout << "The array is increasing ";
}
else {
cout << "No order in this array ";
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.