0
Good evening guys, I’m working on a program that generates a 10x10 matrix, with numbers between 100 and 999, and finally that I make the sum of the digits of each generated number, ex: if it came out 350, 3+5+0=8, if it comes out 495, 4+5+9=18 and so on, that is to add the digits of the 100 elements of this matrix individually, however I can not generate the part of the sum at all, follow the code below to help.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void gen( int [][10] );
void prn( int [][10] );
void sel( int [][10] );
int main()
{
    int n[ 10 ][ 10 ];
    gen( n );
    prn( n );
    sel( n );
    return 0;
} 
void gen( int g[][10] )
{
    srand(time(0));
    for( int i = 0 ; i < 10 ; i++ )
        for( int j = 0 ; j < 10 ; j++ )
            g[ i ] [ j ]= 100+ rand()%899 + 1 ;
}
void prn( int p[][10] )
{
    for( int i = 0 ; i < 10 ; i++ )
    {
        for ( int j = 0 ; j < 10 ; j++ )
            cout << p[ i ][ j ] << '|';
        cout << endl;
    }
void sel( int s[][10] )
{
    for( int i = 0 ; i < 10 ; i++)
        for()
}    
}
I suggest lowering the scope of the question to something like 'function' that adds the digits of a number'.
– epx
you wrote a program in C. Just switched the headers. It was really a program in C?
– arfneto