Q1_20251109113137.webp
D

Q1_20251109113137.webp

Question 3:
(3 marks)
The given file Q3.cpp contains statements to inputting data into a 1-D array of integers. You should
write the statements to compute the sum of the squares of the indices at which the elements
have negative values.
For example, if the array is [5, -2, 3, -7], the indices of negative values are 1 and 3 → sum = 1²+
3² = 10.
Notes:
-Do not edit given statements in the main function.
- You can create new functions if you see they are necessary.
Sample input and output:
Please enter the size of the array: 5
a[0]=10
Please enter the size of the array: 5
a[0]=10
a[1]=-13
a[1]=15
a[2]=7
a[2]=15
a[3]=-25
a[3]=25
a[4]=23
a[4]=48
Output for marking:
Output for marking:
OUTPUT:
OUTPUT:
Zoom
- FUO
+ 100%
Close
Chưa có bình luận nào.

Thông tin

Category
PRF193
Thêm bởi
dinhtrong93
Ngày thêm
Lượt xem
1,057
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom