Question

double minimum(double data[], int len) { double min_val = data[0]; /* TODO: Write the code that...

double minimum(double data[], int len) {
double min_val = data[0];

/* TODO: Write the code that goes here */

return min_val;
}

please this in c programming to write a code

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

Output:

Raw Code:

#include<stdio.h>
double minimum(double data[],int len){
   double min_val = data[0]; // Initializing min_val with data[0]
   for (int i=1;i<len;i++){ // This loop will iterate all the numbers in a data array except first.
       if (data[i]<min_val){ // comparing data[i] and min_val
           min_val = data[i]; // If the data[i] value is less then the min_val then update the min_val to data[i].
       }
   }
   return min_val;
}
void main()
{
   double arr[] = {1.2,6.4,0.9,555,3.56,3.2,6.4,10.0}; // Initializing double arr with values.Here the array size is 8.
   int len = 8; // Assigining 8 to len variable.
   printf("%lf\n",minimum(arr,len));// Calling minimum function with arr and len as parameters and printing the returned value.
}

Add a comment
Know the answer?
Add Answer to:
double minimum(double data[], int len) { double min_val = data[0]; /* TODO: Write the code that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 2a Please code in Ocaml: TODO: Implement an OCaml function sum_top_4 : int list -> int...

    2a Please code in Ocaml: TODO: Implement an OCaml function sum_top_4 : int list -> int list, which takes a list of integers and adds the sum of the top four elements to the head of the list (e.g. the input list [1;1;1;1;3;2] should become the output list [4;1;1;1;1;3;2]). starter code: let sum_top_4 (xs : int list) : int list = (* your work here *) [ ]

  • CONSIDER THE FOLLOWING CODE: double SumString(string x, int n) {       double sum = 0;      ...

    CONSIDER THE FOLLOWING CODE: double SumString(string x, int n) {       double sum = 0;       for (int i = 0; i < n; i += 2)             sum += x.length();       return sum; } ///////////////////////////////////////////////////////// void Question() {       string a = "string";       int num = a.length();       double total = SumString(a, num);       cout << "The total is: " << total << endl; } Select one: a. The total is: 14.0 b. The total is: 20.0...

  • Please write the complete code in C. Write a C function that prints the minimum spanning...

    Please write the complete code in C. Write a C function that prints the minimum spanning tree of a graph. At the end, print the weight of the spanning tree. A suggested report format is shown in the following example. Source Vertex To Vertex Weight A B 2 A C 4 B D 3 D E 1 Total weight of spanning tree: 10 Your main program will read a graph from DataIn file to an adjacency table before calling the...

  • C++ Write a function so that the main() code below can be replaced by the simpler...

    C++ Write a function so that the main() code below can be replaced by the simpler code that calls function MphAndMinutesToMiles(). Original main(): int main() { double milesPerHour; double minutesTraveled; double hoursTraveled; double milesTraveled; cin >> milesPerHour; cin >> minutesTraveled; hoursTraveled = minutesTraveled / 60.0; milesTraveled = hoursTraveled * milesPerHour; cout << "Miles: " << milesTraveled << endl; return 0; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #include <iostream> using...

  • //codes in DynamicString.cpp #include "DynamicString.h" int DynamicString::myStringLen(const char* str){ //TODO::Implement me return -1; } DynamicString::DynamicString(){ //TODO::1::Implement...

    //codes in DynamicString.cpp #include "DynamicString.h" int DynamicString::myStringLen(const char* str){ //TODO::Implement me return -1; } DynamicString::DynamicString(){ //TODO::1::Implement me } DynamicString::DynamicString(const char* str){ //TODO::1::Implement me } int DynamicString::len() const{ //TODO::1::Implement me return -1; } const char* DynamicString::c_str() const{ //TODO::1::Implement me return nullptr; } char& DynamicString::char_at(int position){ //TODO::1::Implement me char* a = new char('a'); return *a; } char DynamicString::char_at(int position) const{ //TODO::1::Implement me return 'a'; } char& DynamicString::operator[](int position){ //TODO::1::Implement me char* a = new char('a'); return *a; } char DynamicString::operator[](int position) const{...

  • Please write code in C++ class S ( private: int data; public: S0 0; S(int n);...

    Please write code in C++ class S ( private: int data; public: S0 0; S(int n); void Inc0; void Grow(int n); Problem 3: Given: void Reset(int n); int GetSO:3; S:S (int n) ( data n;) void S: Inc0 (data++) void S::Grow(int n) {data + =n;} void S: Reset(int n) data n;) int S: GetsO f return data; ) Find: int maino t S a(8), b(2); a.Inc0; cout<ca.GetsOendl; I.. b.Grow(4); cout<<b.GetsO<endl; II

  • IN C++: Please write a function called coin_row that takes in a vector (of type int)...

    IN C++: Please write a function called coin_row that takes in a vector (of type int) of coins in order and outputs a coin row solution. ( Find maximum possible sum of elements such that there are no 2 consecutive elements present in the sum.) val set to the value of the optimal solution coin_indices (0-indexed) set to the indices of the coins forming the optimal solution MUST BE DONE WITH DYNAMIC PROGRAMMING. NO RECURSION typedef struct coin_row_solution{ int val;...

  • How do can I update this code (Code A): Code (A) #include using namespace std; int fibonacci(int n) { int a = 0,...

    How do can I update this code (Code A): Code (A) #include using namespace std; int fibonacci(int n) { int a = 0, b = 1, c; if (n <= 1) return n; for (int i = 2; i <= n; i++) { c = a + b; a = b; b = c; } return b; } int fibonacciRecursive(int n) { if (n <= 1) { return n; } return fibonacciRecursive(n-1) + fibonacciRecursive(n-2); } int main() { int n;...

  • Please in C Language Thank you! The following program source code is incomplete 1 #include <stdio.h> 2 3 // TODO:...

    Please in C Language Thank you! The following program source code is incomplete 1 #include <stdio.h> 2 3 // TODO: 1) Add the typedef here: 5// TODO: 2) Modify the parameter of repeat to add irn the function pointer for the function to be called repeatedly: 8 void repeat (int times) for (int k 0; k < times; ++k) 12 // TODO: 3) Add the call to the function pointer here: 14 15 17 void test (void) 18 printf("Test!\n"); 19...

  • C++ language Write a function, int flip(string a[], int n); It reverses the order of the...

    C++ language Write a function, int flip(string a[], int n); It reverses the order of the elements of the array and returns n. The variable n will be greater than or equal to zero. Example: string array[6] = { "a", "b", "", "c", "d", "e" }; int q = flip(array, 4); // returns 4 // array now contains: "C" "" "" "a" "d" "e" O Full Screen 1 code.cpp + New #include <string> 2 using namespace std; 3 4- int...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT