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

Array Daily Challenge

1. The document is a student report from Sri Krishna College of Engineering and Technology detailing performance on a coding challenge involving arrays. 2. The student attempted 3 coding problems - counting pairs in an array whose sum equals a given value, reversing an array, and performing operations on a matrix. 3. For all problems, the student's answers were marked as wrong and received 0 marks out of the possible 10 marks for each problem.

Uploaded by

AJIN RIBIA P
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)
51 views4 pages

Array Daily Challenge

1. The document is a student report from Sri Krishna College of Engineering and Technology detailing performance on a coding challenge involving arrays. 2. The student attempted 3 coding problems - counting pairs in an array whose sum equals a given value, reversing an array, and performing operations on a matrix. 3. For all problems, the student's answers were marked as wrong and received 0 marks out of the possible 10 marks for each problem.

Uploaded by

AJIN RIBIA P
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

Sri Krishna College of Engineering and Technology

Name :AJIN RIBIA P Email :[email protected]


Roll no:22ECE011 Phone :9488470127
Branch :SKCET Department :ECE
Batch :2022_26 Degree :BE-ECE

2022_26_I_PSP using CPP_IRC

PSCPP_DailyChallenge_Arrays

Attempt : 1
Total Mark : 30
Marks Obtained : 0

Section 1 : Coding

1. Count the number of pairs in an integer array whose sum equals the
given sum (all elements are unique).

Answer
// You are using GCC
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int sum,n,j,i,num=0;
int arr[n];
cin>>sum>>n;
for(i=0;i<n;i++)
{
cin>>arr[n];
}
for(j=0;j<n/2;j++)
{
if(arr[i]+arr[j]==sum)
{
num=num+1;
}
}
cout<<num;
}

Status : Wrong Marks : 0/10

2. Problem Statement
Given an array of elements , reverse the array
Array : 1,2,3,4,5
The output array should be : 5,4,3,2,1

Note: Get the Input Dynamically, Size of the array will Not be Provided.

Answer
// You are using GCC
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int i;
int arr[5];
for(i=0;i<5;i++)
{
cin>>arr[i];
}
for(i=4;i>=0;i--)
{
cout<<arr[i]<<" ";
}
}

Status : Wrong Marks : 0/10

3. Problem statement
Manju wants to perform certain operations in an array to clear the coding
round. Write a program to obtain a matrix and perform the following
operations:
Sum of diagonal elements of a matrix.
Sum of row elements of a two-dimensional array
Sum of column elements of a two-dimensional array.

Answer
// You are using GCC
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int n,m,i,j,diagsum=0,row1=0,row2=0,row3=0;
int a[i][j];
cin>>n>>m;
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
cin>>a[i][j];
}
}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
if(i==j)
{
diagsum=diagsum+a[i][j];
}
else
{
diagsum=diagsum+0;
}
}
}
cout<<"Diagsum= "<<diagsum<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
if(i==0)
{
row1=row1+a[i][j];
}
}

}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
if(i==1)
{
row2=row2+a[i][j];
}
}
}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
if(i==2)
{
row3=row3+a[i][j];
}
}
}
// cout<<"Diagonal Elements : "<<diagsum<<endl;
cout<<"Row 1 : "<<row1<<endl;
cout<<"Row 2 : "<<row2<<endl;
cout<<"Row 3 : "<<row3<<endl;
}

Status : Wrong Marks : 0/10

You might also like