Question

In: Computer Science

Ceate a two dimensional array of int type to hold scores (on a scale of 0...

Ceate a two dimensional array of int type to hold scores (on a scale of 0 to 100) for 10 students (row) for 3 courses (columns) and initialize the array with your preferred data. All the students get 10 bonus points for course #2 (index 1) . Use for a loop to add the bonus points.

c programming language

Solutions

Expert Solution

Source code of the program and its working are given below.Comments are also given along with the code for better understanding.Screen shot of the code and output are also attached.If find any difficulty, feel free to ask in comment section. Please do upvote the answer.Thank you.

Working of the code

  • Program declare a 2D array of size 10 x 3
  • Using nestead for loop,elements of the array are entered
  • Outer for loop iterate through number of students
  • Inner for loop iterate through number of courses
  • Each score of students are read using scanf() function
  • Bonus points 10 is added to second course score(at index 1) of each student
  • Check whether adding bonus points exceeds score 100 or not
  • if yes set score to 100
  • Using nestead for loop,scores of students after adding bonus points are printed

Source code

#include<stdio.h>
int main()
{
   //creating a two dimensional array of size 10 X 3
   int scores[10][3],i,j;
   //Entering 10 student's marks
   for(i=0;i<10;i++)
   {
       printf("Enter the scores of student %d ",i+1);
       //for each student,marks of three courses added
       for(j=0;j<3;j++)
           //reading scores
           scanf("%d",&scores[i][j]);
   }
   //10 point bonus is added to course 2 for all students
   printf("\nAdding 10 bonus to course 2........");
   //accessing each student
   for(i=0;i<10;i++)
   {
       //adding 10 points to second course(ie index 1)
       scores[i][1]=scores[i][1]+10;
       //checking if score exceeds 100 if yes set score to 100
       if(scores[i][1]>100)
           scores[i][1]=100;
   }
   printf("\nScores of the students after adding bonus...");
   //printing scores of each student after adding bonus point
   for(i=0;i<10;i++)
   {
       printf("\n\nScores of student %d",i+1);
       for(j=0;j<3;j++)
           printf("\nCourse %d score = %d",j+1,scores[i][j]);
   }
          
}

Screen shot of the code

Screen shot of the output


Related Solutions

For a given two-dimensional array in C as follows (Each int-type element occupies 4 bytes of...
For a given two-dimensional array in C as follows (Each int-type element occupies 4 bytes of memory) int A[8][16]; If the address of A[1][4] is 0x0FFA0040, what is the memory address of A[2][6]?
in java Implement a function print2Darray(int[][] array) to print a formatted 4x4 two dimensional integer array....
in java Implement a function print2Darray(int[][] array) to print a formatted 4x4 two dimensional integer array. When the array contains {{10, 15, 30, 40},{15, 5, 8, 2}, {20, 2, 4, 2},{1, 4, 5, 0}}, Your output should look like: {10 15 30 40} {15 5 8 2}{ 20 2 4 2}{ 1450} Now, implement another function print2DList(ArrayList<ArrayList<Integer>> list) to print a formatted 2D list.
A.) myNums is an array of 50 elements of type int and k is an int...
A.) myNums is an array of 50 elements of type int and k is an int variable. For which one we get the index of out of bounds? a. for (k = 0; k <= 49; k++)     cout << myNums[k] << " "; b. for (k = 1; k < 50; k++)     cout << myNums[k] << " "; c. for (k = 0; k <= 50; k++)     cout << myNums[k] << " "; d. for (k =...
Create a two-dimensional array A using random integers from 1 to 10. Create a two-dimensional array B using random integers from -10 to 0.
This program is for C.Create a two-dimensional array A using random integers from 1 to 10. Create a two-dimensional array B using random integers from -10 to 0. Combine the elements of A + B to create two- dimensional array C = A + B. Display array A, B and C to the screen for comparison. (Note a[0] + b[0] = c[0], a[1] + b[1] = c[1], etc.)
Given that Sale[NUM_ROW][NUM_COLUMN] is a two dimensional array of float- point type and the two constants...
Given that Sale[NUM_ROW][NUM_COLUMN] is a two dimensional array of float- point type and the two constants are defined as follows: #define NUM_ROW 4 #define NUM_COLUMN 4 float Value[NUM_ROW][NUM_COLUMN] = { 2.1, 2.2, 2.3, 2.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.1, 2.2, 2.3, 2.4 }; Write a C++ main function that computes and prints out the following information about this 2d array: (1) The mean of all the Value[][] array elements (0.5 points). (2) The median of all...
C++ ASSIGNMENT: Two-dimensional array Problem Write a program that create a two-dimensional array initialized with test...
C++ ASSIGNMENT: Two-dimensional array Problem Write a program that create a two-dimensional array initialized with test data. The program should have the following functions: getTotal - This function should accept two-dimensional array as its argument and return the total of all the values in the array. getAverage - This function should accept a two-dimensional array as its argument and return the average of values in the array. getRowTotal - This function should accept a two-dimensional array as its first argument...
You will need to use only two arrays:  One array of type int to store...
You will need to use only two arrays:  One array of type int to store all the ID's  One two‐dimensional array of type double to store all the scores for all quizzes Note: The two dimensional array can be represented also with the rows being the students and the columns being the quizzes. How to proceed: 1. Declare the number of quizzes as a constant, outside the main method. (Recall that identifiers for constants are all in CAPITAL_LETTERS.)...
you will create a dynamic two dimensional array of mult_div_values structs (defined below). The two dimensional...
you will create a dynamic two dimensional array of mult_div_values structs (defined below). The two dimensional array will be used to store the rows and columns of a multiplication and division table. Note that the table will start at 1 instead of zero, to prevent causing a divide-by-zero error in the division table! struct mult_div_values { int mult; float div; }; The program needs to read the number of rows and columns from the user as command line arguments. You...
The statement: "int ar[7] = {0};" sets all of the array elements of ar to 0...
The statement: "int ar[7] = {0};" sets all of the array elements of ar to 0 (zero) True False ------------------------------------------- #define SIZE 3 - declares a constant value named SIZE, equal to 3, that is available throughout your program and is immutable. True False ---------------------------------------- Select all of the following that apply to an array: 1. Contiguous storage is storage without any gaps. 2. Arrays make programming complex problems more difficult. 3. An arrays elements are stored contiguously in memory....
How to create a two-dimensional array, initializing elements in the array and access an element in...
How to create a two-dimensional array, initializing elements in the array and access an element in the array using PHP, C# and Python? Provide code examples for each of these programming languages. [10pt] PHP C# Python Create a two-dimensional array Initializing elements in the array Access an element in the array
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT