Відповідь:
C++ code:
#include <iostream>
void inp_arr(double *arr,const unsigned int size){
for(int i = 0; i < size; i++){
std::cout << "arr[" << i << "]: ";
std::cin >> arr[i];
}
void print_arr(double *arr,const unsigned int size){
std::cout << arr[i] << "\t";
std::cout << std::endl;
double sum_arr(double *arr,const unsigned int size){
double sum = 0;
sum += arr[i];
return sum;
int main(){
setlocale(LC_ALL , "Ukrainian");
const unsigned int size = 7;
double arr[size];
inp_arr(arr,size);
print_arr(arr,size);
std::cout << "Сума елементiв = " << sum_arr(arr,size) << std::endl;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
Відповідь:
C++ code:
#include <iostream>
void inp_arr(double *arr,const unsigned int size){
for(int i = 0; i < size; i++){
std::cout << "arr[" << i << "]: ";
std::cin >> arr[i];
}
}
void print_arr(double *arr,const unsigned int size){
for(int i = 0; i < size; i++){
std::cout << arr[i] << "\t";
}
std::cout << std::endl;
}
double sum_arr(double *arr,const unsigned int size){
double sum = 0;
for(int i = 0; i < size; i++){
sum += arr[i];
}
return sum;
}
int main(){
setlocale(LC_ALL , "Ukrainian");
const unsigned int size = 7;
double arr[size];
inp_arr(arr,size);
print_arr(arr,size);
std::cout << "Сума елементiв = " << sum_arr(arr,size) << std::endl;
return 0;
}