The C++ code for the program is :
#include <iostream>
using namespace std ;
int main() {
int a[100]; // the array to be considered
int i,j,n;
int flag = 0;
cout << "enter the size of the array \n";
cin >> n ;
cout << " enter the array \n";
for(i=0;i<n;i++)
{
cin >> a[i];
}
for ( i=0,j=n-1; i < n/2; i++, j--) // run the loop from both the end to compare each element
{
if(a[i]!=a[j]) // check for mismatch
{
flag = 1; // if mismatch found, flag becomes 1
break;
}
}
if(flag == 0)
{
cout << " the elements of the array are same when read from front or back \n";
}
else
{
cout << " the elements of the array are not same when read from front or back \n";
}
}
Screenshot of the program
![#include <iostream> using namespace std; int main() { int a[100]; // the array to be considered int i,j,n; int flag = 0; cout](http://img.homeworklib.com/questions/1600e2c0-a47a-11eb-8910-4107027bd524.png?x-oss-process=image/resize,w_560)
Screenshot of the output :
Lab 7.9 LAB Write a C++ program to check if elements of an array are same...
this program is in C.
Write a program that computes the number of elements in an array divisible by a user specified number. Declare an integer array of size 7 and read the array elements from the user. Then, read a number k from the user and compute the number of elements in the array divisible by k. Consider the following example. 3 elements in this array are divisible by 2 ({2,2,4}). Sample execution of the program for this array...
1. Write a C++ Program to display address of elements of an array using both array and pointers 2. Write a C++ Program to insert and display data entered by using pointer notation. 3. Write a C++ Program to access Array Elements Using Pointer
Write a c program that finds the uncommon elements from two array elements using pointers only . For example : Enter the length of the array one : 5 Enter the elements of the array one: 9 8 5 6 3 Enter the length of the array two: 4 Enter the elements of the array two: 6 9 2 1 output: 8 5 3 2 1 void uncommon_ele(int *a, int n1, int *b, int n2, int *c, int*size); The function...
Write a C program convert.c that converts each number in an array by the sum of that number plus 6 modulus 10. A sample input/output: Enter the length of the array: 5 Enter the elements of the array: 3 928 4 14 77 Output: 9 4 0 0 3 The program should include the following function: void convert(int *a1, int n, int *a2) The function converts every element in array a1 of length n to an output array a2. The...
In C only Please! This lab is to write a program that will sort an array of structs. Use the functions.h header file with your program. Create a source file named functions.c with the following: A sorting function named sortArray. It takes an array of MyStruct's and the length of that array. It returns nothing. You can use any of the sorting algorithms, you would like though it is recommended that you use bubble sort, insertion sort, or selection sort...
Write a C++ program that will create an array with a given number of elements. Use size = 10 for demonstration purposes, but write the program where the size of the array can be changed by changing the value of one constant. Fill the array with random numbers between 0 and 100. Write the program to perform the following operations: 1. Find and display the largest value in the array. 2. Find and display the smallest value in the array....
Write a program that passes an array of 100 elements (from 1 to 100) to a function which is called MultipleOf7 as an input and this function should check if these elements are multiples of 7 or not. The output of the function should be an array that includes the elements that are multiples of 7. (MATLAB CODE)
1. (100 pts) Write a program that swaps the elements of an array pairwise. Start from the left of the array, take 2 elements at a time and swap the two elements. Continue in this fashion until you reach the end of the array. Declare an integer array of size 10 and place random numbers in the range [0?9]. Print the original array, pairwise swap the elements of the array and print the final array after swap. Consider the following...
Introduction: In this lab, you will write a MIPS program to read in (up to) 50 integer values from the user, store them in an array, print out the amay, one number per line, reverse the elements in the array and finally print out the elements in the just-reversed) array. Feel free to do this lab and all assembly programming labs) in Windows. You must use MARS Getting started: l. In MARS, create a new assembly file with the name...
Write a C++ program to : Create array arr1 of size 10 Assign values to elements such that - say index = i, arr1[i] = 10 - i. Print arr1 Create arr2 and copy alternate elements from arr1 starting from index 1. Print arr2. Sort arr1 in ascending array and print its elements from indices 3 to 8 Print every output on a different line and separate array elements by spaces.