For C 1 Remove Duplicates Write a function that is passed a
For C++
1) Remove Duplicates : Write a function that is passed an array of integers sorted in non-increasing order and returns with all of the duplicate entries removed. Take care of following steps:1. Manually create a file named Numbers.txt in the assignment folder and fill it with a list of integral numbers (type one below the other) in non-increasing order.2. In main function, read the above file and create an integer array to store the above numbers. See Disclaimer in previous question. 3. In removeDuplicate function, do not create any additional array. The original array has to be modified such that it remains sorted and doesn’t contain any duplicate entry. 4. From main function, display the modified array. TIP: Since the array dimensions can’t be reduced (no use of vectors) after removal of duplicate entry, decide what information should removeDuplicate return to mainfunction to use to print the possibly modified array.
Output Examples: Original array: 50 21 21 10 8 8 5 3
Modified array: 50 21 10 8 5 3
2) Check Palindrome : Palindrome is a sequence of characters or numbers which reads the same backward or forward. Examples: abcba, pqrssrqp, 13531 are palindromes Write a program that checks if a character array is palindrome or not. The size of the array is user-defined in main. Disclaimer: In C++, variable length arrays are not legal. g++ compiler allowsthis as an \"extension. Other compilers may or may not. For this assignment, you may use variable length and trust g++ in CSE server. However, legal way of handling such variable length arrays in C++ is using Dynamic Memory Allocation for arrays (creating memory during runtime) which we will study in later chapter. Create a user-defined character array by calling a function createArray. Create another function checkPalindrome that accepts the character array as parameter and returns to main function, a boolean status of the sequence being a palindrome or not. Display the status of the sequence from the main function.
Solution
1)
#include <iostream>
using namespace std;
const int SIZE=20;
int main ()
{
int numbs[SIZE], value, idx,n;
cout<<\"PLease enter size of an array\"<<endl;
cin>>n;
cout << \"Please enter in a series of numbers \"<<endl;
for(idx = 0; idx < n; idx++)
cin >>numbs[idx];
cout<< numbs[0] << \" \";
for (int i = 1; i < n; i++)
{
bool matching = false;
for (int j = 0; (j < i) && (matching == false); j++)if (numbs[i] == numbs[j]) matching = true;
if (!matching) cout<< numbs[i] << \" \";
}
}
2)
#include<iostream>
using namespace std;
int main(){
char string1[20];
int i, length;
int flag = 0;
cout << \"Enter a string: \";
cin >> string1;
length = strlen(string1);
for(i=0;i < length ;i++){
if(string1[i] != string1[length-i-1]){
flag = 1;
break;
}
}
if (flag) {
cout << string1 << \" is not a palindrome\" << endl;
}
else {
cout << string1 << \" is a palindrome\" << endl;
}
system(\"pause\");
return 0;
}


