Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void Unos(float [], int);
- float Suma(float [], int);
- int main() {
- const int v = 6;
- float niz[v];
- Unos(niz, v);
- cout << "Suma elemenata s neparnim indeksom iznosi: " << Suma(niz, v) << ".";
- system("pause>0");
- return 0;
- }
- void Unos(float niz[], int v) {
- for(int i = 0; i < v; i++) {
- cout << "Unesite [" << i << "] element niza: ";
- cin >> niz[i];
- }
- }
- float Suma(float niz[], int v) {
- int suma = 0;
- for(int i = 1; i < v; i += 2) {
- suma += niz[i];
- }
- return suma;
- }
Advertisement
Add Comment
Please, Sign In to add comment