Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cout << "Enter the number of elements" << endl;
- cin >> n;
- int* A;
- A = new int[n];
- int sum = 0;
- int sum2 = 0;
- int i = 0;
- cout << "Enter the elements" << endl;
- for (i = 0; i < n; i++) {
- cin >> A[i];
- sum = sum + A[i];
- sum2 = sum2 + pow(A[i], 2);
- }
- if (sum % 2 == 0) {
- cout << "Sum of array elements is _even_" << endl;
- }
- else {
- cout << "Sum of array elements is _odd_" << endl;
- }
- if (sum % 2 == 0) {
- cout << "Sum^2 of array elements is _even_" << endl;
- }
- else {
- cout << "Sum^2 of array elements is _odd_" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement