Cuimpiete the two programs shown below: Name this program one.c -This number of
ID: 3872931 • Letter: C
Question
Cuimpiete the two programs shown below: Name this program one.c -This number of times each v 1. program takes the name of an input file from the command line, counts the owel occurs in the text, and prints the percentage of the time that each vowel was seen. ou can assume that the file specified on the command line will always exist. Remember that a calculated as: occurrences of that vowel percentage is - 100 total number of vowels Contents of datal Roll TIDE Roll! Contents of data2 One fish Two fish Red fish Blue Fish a.out datal o, 0.000000 percent, were a/A 1, 25.000000 percent, were e/E 1, 25.000000 percent, were 1/1 2, 50.000000 percent, were o/o o, 0.000000 percent, were u/ /a.out data2 o, 0.000000 percent, were a/A 3, 30.000000 percent, were e/E 4, 40.000000 percent, were i/I 2, 20.000000 percent, vere o/o 1, 10.000000 percent, were u/U integers are in ascerlding order (each number is at least as large as the one before it) or descending order (each number is no larger file will always contain legal integers. You must use the main routine shown below for this program. You simply have to write the two functions shown in red. program two.c-This program reads ten integers from standard input. It then determines if these than the one before it) or not in ascending/descending order. You can assume the input # include int isAscending (int [ 1): // returns 1 if numbe int isDescending (int [ ); // returns i it numbers are descending, els rs are ascending, else 0 1 int main (void) int array [10]: printf ("Enter ten integers") for (int arO ; aExplanation / Answer
Source Code:
#include<stdio.h>
#include<string.h>
#include <stdbool.h>
bool isAscending(int arr[], int size);
bool isDescending(int arr[], int size);
// test isAscending function
int main() {
int arr[3];
printf("Enter The array values");
for(int i=0;i<10;i++)
{
scanf("%d",&arr[i]);
}
if ( isAscending(arr, 10) ) {
printf(" The values are in ascending");
} else if(isDescending(arr,10)){
printf(" The values are in descending ");
}
else
{
printf(" The values are neither descending nor ascending ");
}
return 0;
}
// check if array's elements are in ascending order
bool isAscending(int arr[], int size) {
for (int i = 0; i < size - 1; i++) {
if (arr[i] > arr[i+1]) {
return false;
}
}
return true;
}
bool isDescending(int arr[], int size)
{
for (int i = 0; i < size - 1; i++) {
if (arr[i] < arr[i+1]) {
return false;
}
}
return true;
}
Output:
2
3
4
5
6
7
8
9
10
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.