+ 1

Write a function that takes 3 arguments : the name of 'FLOAT' array,the array size,and a 'FLOAT' value.[continued]

[continued] Have the function set each element of the array to 'FLOAT' value ?

14th Jan 2017, 8:26 AM
Siddharth Naithani
Siddharth Naithani - avatar
2 ответов
+ 3
void function (float arr[], int n, float x){ int i=0; for (i=0; i<n; i++){ arr[i] = x; } }
14th Jan 2017, 9:36 AM
Akash Middinti
+ 1
#include <iostream> using namespace std; void func(float *arrPtr, int arrSize, float arrVal) { if(arrPtr != NULL) { for(int i = 0; i < arrSize; i++) { arrPtr[i] = arrVal; } } } int main() { //Prg 1 Start float arrFloat[10]; func(arrFloat,10,50); for(int i = 0; i < 10; i++) { cout << "Arr[" << i << "] => " << arrFloat[i] << endl; } }
15th Jan 2017, 2:10 PM
Bharath N