c1

utorak, 11. prosinca 2012.

Matrix 50 x 50 and secondary diagonal

/*
Question:
Make a logic of program which will use a matrix [50][50]....User types the numbers, and numbers must be less or equal to 50, if that condition is not satisfied, you need to repeat the number m....Find and multiply the numbers on secondary diagonal of matrix....(secondary diagonal goes from upper right side to downer left)

*/

HERE YOU CAN FIND MORE C++ PROGRAMS ON REDGAGE







#include <iostream>
using namespace std;
int main()
{
    int x=3;
    int y=3;
    int n[x][y];
    int m;
    int sum=0;
    cout<<" Type the numbers of matrix: "<<x<<" x "<<y<<endl;
    for(int i=0;i<x;i++){
            for(int j=0;j<y;j++){
                  
            cout<<"Position "<<i+1<<" - "<<j+1<<" is: ";
            cin>>m;
            if(m<51){
            n[i][j]=m;      
            }
            else{
                 j--;
                 cout<<" Type the number which is smaller or equal to 50 "<<endl;
                 }
                    }
            }
  
    cout<<"Matrix is: "<<endl;
    for(int i=0;i<x;i++){
            cout<<endl;
          
            sum=sum+n[i][x-1-i];
            cout<<n[i][x-1-i]<<"   ";
                
                  
                  
            }
    cout<<endl<<endl<<"The sum of secondary diagonal is: "<< sum <<endl;
    cout<<endl;
  
  
    system("PAUSE");
    return EXIT_SUCCESS;
}



HERE YOU CAN FIND MORE C++ PROGRAMS ON REDGAGE


Nema komentara:

Objavi komentar