February 19th, 2022
[Scroll to the bottom of this page to discuss stuff].
WAP to input a 2D array of size NxM (input N and M from user) and then print the sum of the border elements of the array. eg, if the array is:
1 2 3
4 5 6
7 8 9
then the sum of the border elements are: 1 + 2 + 3 + 6 + 9 + 8 + 7 + 4 = 40
There are 4 schools with 5 subjects each and each subject has 20 students. WAP to input the marks of each student in each subject of each school. Now print the average marks of each school.
Hint: You need to use a 3D array here.
There are 5 subjects and each subject can have any number of students in it.
WAP to input the marks of each student in each subject. Now print the average marks of each subject.
Hint: you may need to use jagged arrays (just read definition from here, we’ll learn about pointers tomorrow. This question can be solved without jagged arrays too, just keep the rows sufficiently large and fill them with 0).
Basically it’s a 2D array with a variable number of rows and columns. eg.,
{ {12, 56, 86},
{23, 45, 67, 56},
{34, 56},
{45, 67, 89},
{56, 78, 90} }
WAP to accept a sentence from user and print the sentence with each word reversed.
eg., if the sentence is: “I am a student” then the output should be: “I ma a tneduts”.
WAP to accept a sentence from user and print the sentence in reverse.
eg., if the sentence is: “I am a student” then the output should be: “student a am I”