1) если нужно найти произведение элементов с нечетными индексами:
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
signed main() {
int a[20];
srand(time(NULL));
for(int i = 0; i < 20; i++)
a[i] = rand()%46 - 19;
for(auto i: a)
cout << i << " ";
cout << "\n";
long long ans = 1;
for(int i = 0; i < 20; i++)
if(i % 2 == 1)
ans *= a[i];
cout << ans;
}
2) Если нужно найти произведение элементов с нечетными порядковыми номерами:
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
signed main() {
int a[20];
srand(time(NULL));
for(int i = 0; i < 20; i++)
a[i] = rand()%46 - 19;
for(auto i: a)
cout << i << " ";
cout << "\n";
long long ans = 1;
for(int i = 0; i < 20; i++)
if((i+1) % 2 == 1)
ans *= a[i];
cout << ans;
}
1) int() - Целые числа - –27885; –156; 25; 152
2) float() - Действительные числа - 25.56; 5.0; –365.5633
3) str() - Строковые - "1vdkdv", "t"
4) Вool() - Логические - True, False
Объяснение: