A single array containing the elements (5,2,3,7,8,1) 1) Find and print the sum o
ID: 3617590 • Letter: A
Question
A single array containing the elements (5,2,3,7,8,1)1) Find and print the sum of squared elements of the array
1) Sort all the elements less than 7 in descending order
2) Find the fifth element, print its value
4) Print the elements of the matrix, which more than No. 3 A single array containing the elements (5,2,3,7,8,1)
1) Find and print the sum of squared elements of the array
1) Sort all the elements less than 7 in descending order
2) Find the fifth element, print its value
4) Print the elements of the matrix, which more than No. 3
Explanation / Answer
//Hope this will helpyou.# include <iostream> using namespace std; int main() {
int mat[6]={5,2,3,7,8,1}; int temp,i,j,x,sum=0;
for (i=0;i<6;i++) { sum = sum+mat[i]*mat[i]; }
cout<<" the sum of squre number iz:"<<sum<<endl;
for(i=0;i<6;i++) for(j=i+1;j<6;j++) {
if(mat[i]<7&&mat[j]<7) { if(mat[i] < mat[j]) { temp = mat[i]; mat[i]=mat[j]; mat[j]= temp; } } } cout<<endl<<"After decreasing order <7 array is:"; for(i=0;i<6;i++) cout<<mat[i]<<", ";
cout<<endl;
cout<<"5th element is:"<<mat[4]<<endl;
cout<<"Element more than 3 are :"<<endl; for(i=0;i<6;i++) if(mat[i] >3) cout<<mat[i]<<endl; system("pause"); return 0; }
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.