Computer Science, asked by nandanass, 8 months ago

Write array declaration of scores of 100 students

Answers

Answered by akshansh27
3

Explanation:

Write array declarations for the following:

a. Scores of 100 students : int score[100];

b. English letters : char a[10];

c. A list of 10 years : int year[12];

d. A list of 30 real numbers : float n[30];

2. Write array initialization statements for the following:

a. An array of 10 scores: 89, 75, 82, 93, 78, 95, 81, 88, 77,and 82

Ans: int score[10] = {89, 75, 82, 93, 78, 95, 81, 88, 77, 82};

b. A list of five amounts: 10.62, 13.98, 18.45, 12.68, and 14.76

Ans: float amt[5] = { 10.62, 13.98, 18.45, 12.68, 14.76 };

c. A list of 100 interest rates, with the first six rates being 6.29, 6.95,

7.25, 7.35, 7.40 and 7.42.

Ans: float rate[100] = { 6.29, 6.95, 7.25, 7.35, 7.40, 7.42};

d. An array of 10 marks with value 0.

Ans: int mark[10]={NULL}; or int mark[10]={0,0,0,0,0,0,0,0,0,0};

e. An array with the letters of VIBGYOR.

Ans: char c[7]={'V','I','B','G','Y','O','R'};

f. An array with number of days in each month.

Ans: int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};

3. Write a C++ code to input values into the array: int ar[50];

int i , ar[50];

for (i=0;i<50;i++)

{

cout << ”Enter value”;

cin << ar[i];

}

4. Write a C++ code fragment to display the elements in the even positions of the array

float val[100];

int i;

float val[100];

for (i = 0; i <100; i += 2)

{

cout << ”Enter value”;

cin << ar[i];

}

Similar questions