Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

CS 100 – Computational Problem Solving

Fall 2017
Quiz 4

Time: 10 min Total Marks: 10

Name: ___________________________________________

Roll Number: _______________________ Section: __________

Q1. Consider the following array: [5]

int a[] = {1, 2, 3, 4, 5, 4, 3, 2, 1, 0};

What is the value of total after the following loops complete?

int total = 0;

for (int i =1; i < 10; i = i+2)

total = total + a[i];

Q2. Write code that fills an array double a[10] with the given set of values below.
[5]

1 4 9 16 25 36 49 64 81 100

double values[10];
for (int i = 0; i < 10; i++)
{

values[i] = (i + 1) * (i + 1);

You might also like