[go: up one dir, main page]

0% found this document useful (0 votes)
6 views4 pages

C 2 Darray

The document contains the results of a programming assessment for a student named Sarthak Jain, detailing their performance on two coding problems. The first problem involves calculating population sums in a matrix, while the second requires modifying a 2D matrix by removing a specified row and column. Both problems received a perfect score of 10/10.

Uploaded by

srai200418
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

C 2 Darray

The document contains the results of a programming assessment for a student named Sarthak Jain, detailing their performance on two coding problems. The first problem involves calculating population sums in a matrix, while the second requires modifying a 2D matrix by removing a specified row and column. Both problems received a perfect score of 10/10.

Uploaded by

srai200418
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

VIT - Vellore

4
10

10

10

10
T0

T0

T0

T0
BC

BC

BC

BC
Name: SARTHAK JAIN . Scan to verify results
24

24

24

24
Email: sarthak.jain2024@vitstudent.ac.in
Roll no: 24BCT0104
Phone: 9999999999
Branch: PRIYADHARSINI M_OOPS
Department: admin
Batch: VL2024250502354
Degree: admin
4

04

4
10

10

10
01
BCSE102P_Structured and Object Oriented Programming
0

T0

T0
CT

CT
BC

BC
Lab_VL2024250502354
B

B
24

24

24

24
VIT V_BCSE102P_Lab 2_CY_2D Array

Attempt : 1
Total Mark : 20
Marks Obtained : 20

Section 1 : Coding
4

4
1. Problem Statement
10

10

10

10
T0

T0

T0

T0
BC

BC

BC

In a town planning project, Sarah is tasked with analyzing the population BC


24

24

24

24
distribution in a square region represented by an NxN matrix. She needs to
divide the region into four quadrants and calculate the sum of populations
in each quadrant.

Can you write a program to help Sarah find the population sums for the top-
left, top-right, bottom-left, and bottom-right quadrants?

Answer
#include <stdio.h>
04

04

4
10

10

int main(){
1

1
T0

T0

T0

T0

int s=0;
BC

BC

BC

BC
24

24

24

24
int t;
4

4
10

10

10

10
scanf("%d\n",&t);
T0

T0

T0

T0
for(int i=1,s=0;i<=t;i++){
BC

BC

BC

BC
int n;
24

24

24

24
scanf("%d\n",&n);
int arr[n][n];
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
scanf("%d ",&arr[i][j]);
}
}
for(int i=0;i<n/2;i++){
for(int j=0;j<n/2;j++){
s=s+arr[i][j];
4

04

4
10

10

10
}

01
0

T0

T0
CT

CT
}
BC

BC
B

B
printf("%d ",s);
24

24

24

24
s=0;
for(int i=0;i<n/2;i++){
for(int j=n/2;j<n;j++){
s=s+arr[i][j];
}
}
printf("%d ",s);
s=0;
for(int i=n/2;i<n;i++){
for(int j=0;j<n/2;j++){
4

4
10

10

10

10
s=s+arr[i][j];
T0

T0

T0

T0
}
BC

BC

BC

} BC
24

24

24

24
printf("%d ",s);
s=0;
for(int i=n/2;i<n;i++){
for(int j=n/2;j<n;j++){
s=s+arr[i][j];
}
}
printf("%d ",s);
s=0;
printf("\n");
04

04

4
10

10

}
1

1
T0

T0

T0

T0

}
BC

BC

BC

BC
24

24

24

24
Status : Correct Marks : 10/10
4

4
10

10

10

10
T0

T0

T0

T0
BC

BC

BC

BC
2. Problem Statement
24

24

24

24
Emma, a data analyst, needs to adjust a dataset represented as a 2D
matrix by removing a specified row and column. Write a program to help
Emma achieve this task.

Given the matrix and the indices of the row and column to be removed,
print the modified matrix.

Answer
4

04

4
10

10

10
01
#include <stdio.h>
0

T0

T0
CT

CT
int main(){
BC

BC
B

B
24

24

24

24
int n1;
scanf("%d\n",&n1);
for(int z=1;z<=n1;z++){
int a=0,b=0;
int m,n;
int r,c;
scanf("%d %d",&m,&n);
int arr[m][n];
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
scanf("%d",&arr[i][j]);
4

4
10

10

10

10
}
T0

T0

T0

T0
}
BC

BC

BC

BC
24

24

24

24
scanf("%d %d",&r,&c);
int newarr[m-1][n-1];
for(int i=0;i<m;i++){
if(i==r){
continue;
}
b=0;
for(int j=0;j<n;j++){
if(j==c){
continue;
}
04

04

4
10

10
1

newarr[a][b]=arr[i][j];
T0

T0

T0

T0

b++;
BC

BC

BC

BC
24

24

24

24
24 24 24 24
BC BC B BC

}
T0 T0 CT
0 T0

}
1 10 10 10

}
}
04 4 4 4

}
}
a++;

Status : Correct
24 24 24 24
for(int i=0;i<m-1;i++){
for(int j=0;j<n-1;j++){

BC BC BC BC
T0 T0 T0 T0
10 10 10 10
printf("%d",newarr[i][j]);

4 4 4 4

24 24 24 24
BC BC B CT BC
T0 T0 T0
1 04 10 01 10
4 04 4

24 24 24 24
BC BC BC BC
Marks : 10/10

T0 T0 T0 T0
10 10 10 10
4 4 4 4

You might also like