Computer Science, asked by bipashasen, 7 months ago

17. Write a code to calculate and display total marks and percentage of a student from a given list storing
the marks of a student.
Program to multinly an element by 2 if it is an odd index for a given list containing both numbers in python

Answers

Answered by arrpanglkr
2

please MARK me AS the BRAINLIEST

using namespace std;

// Function to calculate sum

void EvenOddSum(int arr[], int n)

{

int even = 0;

int odd = 0;

for (int i = 0; i < n; i++) {

// Loop to find even, odd sum

if (i % 2 == 0)

even += arr[i];

else

odd += arr[i];

}

cout << "Even index positions sum " << even;

cout << "\nOdd index positions sum " << odd;

}

// Driver function

int main()

{

int arr[] = { 1, 2, 3, 4, 5, 6 };

int n = sizeof(arr) / sizeof(arr[0]);

EvenOddSum(arr, n);

Answered by Equestriadash
13

The following codes have been written using Python.

Source code:

n = int(input("Enter the number of subjects: "))

l = list()

for i in range(n):

 x = float(input("Enter the marks: "))

 l.append(x)

print(l, "is the given list of marks.")

print()

tot = int(input("Enter the total marks of the test: "))

ntot = n*tot

ftot = sum(l)

print("Total marks: ", ftot)

print("Percentage: ", (ftot/ntot)*100)

Attachments:
Similar questions