Use the language c++ and answer the followig questions:
1) Write a function that will take an empty array of size 25 as
input and modify each element such that the array stores values
from 1 to 25.
2) Write a function to print this array to show your output.
3) Write a function to iterate through that array and print whether
or not a number is: even, odd, and prime.
... Make sure to call your functions in main() and show your
output!
#include<iostream>
#include<iomanip>
using namespace std;
int prime(int n)
{
int check = 0,j;
for( j=2;j<=n/2;j++)//for loop
{
if(n%j==0)
{
check = 1;
break;
}
}
return check;
}
void insert_in_arry(int arr[])
{
int i;
for(i=0;i<25;i++)
{
arr[i]=i+1;
}
}
void print(int arr[])
{
int i;
for(i=0;i<25;i++)
cout<<arr[i]<<" ";
cout<<endl;
}
void print_even_odd_prime(int arr[])
{
int i;
cout<<"Even number: ";
for(i=0;i<25;i++)
{
if(arr[i]%2==0)
cout<<arr[i]<<" ";
}
cout<<"\nOdd number: ";
for(i=0;i<25;i++)
{
if(arr[i]%2!=0)
cout<<arr[i]<<" ";
}
cout<<"\nprime number: ";
for(i=2;i<25;i++)
{
if(!prime(i))
cout<<i<<" ";
}
cout<<endl;
}
int main()
{
int arr[25];
insert_in_arry(arr);
print(arr);
print_even_odd_prime(arr);
return 0;
}
Use the language c++ and answer the followig questions: 1) Write a function that will take...
Use c++ as programming language. The file needs to be created ourselves (ARRAYS) Write a program that contains the following functions: 1. A function to read integer values into a one-dimensional array of size N. 2. A function to sort a one-dimensional array of size N of integers in descending order. 3. A function to find and output the average of the values in a one dimensional array of size N of integers. 4. A function to output a one-dimensional...
In C language Write a program that includes a function search() that finds the index of the first element of an input array that contains the value specified. n is the size of the array. If no element of the array contains the value, then the function should return -1. The program takes an int array, the number of elements in the array, and the value that it searches for. The main function takes input, calls the search()function, and displays...
In C++ Write a function called fillArray that will fill an array of any constantly declared array size variable with random numbers in the range of 1 - 100. Write a function called printArray that will print an array of any size. Write a third function called countEvens which will count and return the number of even numbers in the array. In main create an array that holds 25 ints. Use your functions to fill, print, and count the number...
1. All functions should be written AFTER the main procedure. 2. A function prototype should be written for each function and placed BEFORE the main procedure. 3. Each function should have a comment explaining what it does. 4. Each function parameter should have a comment explaining the parameter. 5. Prompt for the number of elements of the list. 6. Allocate an array whose size equals the number of elements specified by the user. 7. Read into the array the elements...
**IN C*** * In this lab, you will write a program with three recursive functions you will call in your main. For the purposes of this lab, keep all functions in a single source file: main.c Here are the three functions you will write. For each function, the output example is for this array: int array[ ] = { 35, 25, 20, 15, 10 }; • Function 1: This function is named printReverse(). It takes in an array of integers...
c++ #include <iostream> #include <string> using namespace std; /* Write a function checkPrime such that input: an int output: boolean function: Return true if the number is a prime number and return false otherwise */ //TO DO ************************************** /* Write a function checkPrime such that input: an array of int and size of array output: nothing function: Display the prime numbers of the array */ //TO DO ************************************** /* Write a function SumofPrimes such that input: an int output: nothing...
In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.
In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.
This program should use a main function and two other functions named playlist and savelist as follows: The main function: The main function should create an empty list named nums and then use a loop to add ten integers to nums, each integer in the range from 10-90. NOTE: In Python, a list is a data type. See Chapter 7. The main function should then call the playlist function and savelist function, in that order. Both of these functions take...
Language C Code Write a program that takes two integer arrays (A and B) and sums them together (element wise). A third array to accept the result should be passed in as the output argument. Assume the arrays are all the same size. The argument N is the size of the arrays. Your code should provide a function with the following signature: void array Addition (int A[], int B[], int N, int output[]) { } Your code must also provide...