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

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.)
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 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...
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
Build a two dimensional array out of the following three lists. The array will represent a...
Build a two dimensional array out of the following three lists. The array will represent a deck of cards. The values in dCardValues correspond to the card names in dCardNames. Note that when you make an array all data types must be the same. Apply dSuits to dCardValues and dCardNames by assigning a suit to each set of 13 elements. dCardNames = ['2','3','4','5','6','7','8','9','10','J','Q','K','A'] dCardValues = ['2','3','4','5','6','7','8','9','10','11','12','13','14'] dSuits = ["Clubs","Spades","Diamonds","Hearts"] Once assigned your two dimensional array should resemble this : 2...
c++ language Create a file program that reads an int type Array size 10; the array...
c++ language Create a file program that reads an int type Array size 10; the array has already 10 numbers, but your job is to resize the array, copy old elements of array to the new one and make it user input and add an additional 5 slots in the array, and lastly do binary search based on user input. close the file.
1.Declare a two-dimensional array of Strings namedchessboard.
1. Declare a two-dimensional array of Strings named chessboard.2. Declare a two-dimensional array of integers named tictactoe.3. Declare and create a two-dimensional array of chars,tictactoe, with 3 rows, each with 3 elements.4. Create a two-dimensional array of ints, plan, with 2 rows, and and 3 columns and initialize the first row to 8, 20, 50 and the second row to 12, 30, 75. Use member initializer syntax.
Using the Python Program. Can an array hold a mixture of types i.e. int, float, string,...
Using the Python Program. Can an array hold a mixture of types i.e. int, float, string, array within the same array? Show a code segment to remove the last element from a 15 element array named myStuff[]. Please explain the code.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT