// C code
#include<stdio.h>
#include <stdlib.h>
#include <time.h>
//function prototype
void find(char arr[], int size);
//Function definition
void find(char arr[], int size)
{
int lower = 0;
int upper = size - 1;
//select index randomly
int index = (rand() % (upper - lower + 1)) +
lower;
bool condition = false;
for (int i = index-1; i >= 0; i--)
{
//Compare characteres
// to check condition
if ( arr[index]<arr[i])
{
condition =
true;
}
else
{
condition =
false;
}
}
printf("index = %d is selected\n", index);
if (!condition)
{
printf("element does not meet the
conditions.\n");
}
else
{
printf("element meets the
condition.\n");
}
}
//main() function
int main()
{
//to seed the random number with respect
//to time
srand(time(0));
const int size = 10;
//Create array of size 10
char myArr[size];
printf("Enter characters: \n");
for (int i = 0; i < size; i++)
{
printf("Enter character %d: ", (i +
1));
scanf_s(" %c",
&myArr[i]);
}
//Print the array
printf("myArr = [ ");
for (size_t i = 0; i < size; i++)
{
printf("%c, ", myArr[i]);
}
printf(" ]\n");
//Call function
find(myArr, size);
return 0;
}
//Output
//If you need any help regarding this solution........ please leave a comment........ thanks
Write a C program to do the following: 1. Write a C function named find that...
1. Write a C function named find that receives a one-dimensional array of type integer named arr and its size of type integer. The function fills the array with values that are the power of four (4^n) where n is the index. After that, the function must select a random index from the array and move the array elements around the element stored in the randomly selected index Example arr = [1, 4, 16, 64, 256) if the randomly selected...
(c programming): write a program that contains a function named getName, that does not get any parameter and returns a character array of a random name from a constant list of 30 names, in a global array. the function returns that random name. each name in the list is a character string that consists of not more than 20 characters(not including finishing 0). the name consists of only characters from the american alphabet (a-zA-Z) and does not contain any "white"...
In C++, write two functions named printArray and deleteRepeats along with a main to test them according to the following specifications. Be sure to use function prototypes and place the actual function definitions after main. printArray will take two parameters: an array of characters and an integer representing the number characters stored in the array. It will print the characters from the array, labeled by their index, to the screen up to the specified size. deleteRepeats will take the same...
3. Write Java methods to accomplish each of the following Write a method named simpleAry which accepts and return nothing. It creates an array that can hold ten integers. Fill up each slot of the array with the number 113. Then, display the contents of the array on the screen. You must use a loop to put the values in the array and also to display them. Write a method named sury which accepts an array of type double with...
Write out C++ code for the following: Declare a templated function that has a return type of T". It has two parameters: An array of T items named arr, and an integer named size. This function is assumed to work with numerical data types. Within the function, create a new T variable named sum and initialize it to 0. Use a for-loop to go from 0 (inclusive) to size (exclusive), adding each element from arr to the sum. Finally, return...
In the space below, write a C function definition for a function named StrLower, which will receive one parameter, a pointer to a null-terminated string (i.e., pointer to char), convert each character in the string to lowercase (using the tolower function from <ctype.h>), and return nothing to the caller. Inside the function definition, you may use a for loop or a while loop. If you use any variables other than the incoming parameter, you must define them locally in the...
C++ 1) Write a function named WordCount, which determines the number of words in a “C type” string. The function will have one parameter (the address of the string) and will return the number of words (words are separated by one or more spaces). (15 points) 2) Write a function named VowelConsonant which will have three parameters - all “C type” strings. The function will place all vowels (the characters a, e, i, o, u) from the first string into...
Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly. please put comment with code! and please do not just copy other solutions. 1. write the code using function 2. Please try to implement a function after the main function and provide prototype before main function. Total Characters in String Array 10 points Problem 2 Declare a string array of size 5. Prompt the user enter five strings that are...
Write a C function named isSymmetric, the prototype of which is given below, that returns 1 if the elements of an array of integers named myArray of size n are symmetric around the middle. If the array elements are not symmetric, the function should return 0. Both the array and its size are specified as parameters.
write in java 1. Assume the availability of a method named makeLine that can be passed a non-negative integer n and a character c and return a String consisting of n identical characters that are all equal to c. Write a method named printTriangle that receives two integer parameters n and k. If n is negative the method does nothing. If n happens to be an even number, itsvalue is raised to the next odd number (e.g. 4-->5). Then, when k has the value zero, the method prints...