+ 2

How can i calculate d sum of array??

for eg i wll take 11 subject of marks int m[11] then i has to calculate d percentage so what can i do?

6th Jun 2018, 3:57 PM
Harsh Agrawal
Harsh Agrawal - avatar
7 odpowiedzi
+ 4
logic after getting marks of user : for(int i = 0;i<11;i++) { sum = sum + marks[i]; }
6th Jun 2018, 3:59 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 4
it will go long. you have to add all elements. like this sum = mark[0] + mark[1] + mark[2] + mark[3] + mark[4] + mark[5] + mark[6] + mark[7] + mark[8] + mark[9] + mark[10]
6th Jun 2018, 4:05 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 1
int sum =0; for (int i=0;i<m.length; i++){ sum +=m[i]; }
6th Jun 2018, 4:02 PM
T0nd3
0
Raj Chhatrala can i get sum without using loop???
6th Jun 2018, 4:01 PM
Harsh Agrawal
Harsh Agrawal - avatar
0
T0nd3 can i dont use without using loop
6th Jun 2018, 4:04 PM
Harsh Agrawal
Harsh Agrawal - avatar
0
ohhhhh BTW thnxxxx Raj Chhatrala
6th Jun 2018, 4:07 PM
Harsh Agrawal
Harsh Agrawal - avatar
0
Raj Chhatrala if u want to accept m[11] then what can i do??? n where i put 11 subject of marks???
6th Jun 2018, 4:18 PM
Harsh Agrawal
Harsh Agrawal - avatar