Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8156999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:07:51+00:00 2026-06-06T17:07:51+00:00

I have a piece of code ( I’m student ) that should work in

  • 0

I have a piece of code ( I’m student ) that “should” work in theory, but Microsoft’s Visual Studio 2010 seems to have a problem with srand, because it’s not being highlighted like other reserved names.

If I remove srand from Auto_Complete_Matrix then code will compile with no problem.

Function Auto_Complete_Matrix

Error 2 error C2143: error de sintaxis : missing ‘;’ ahead of ‘type’ c:\users\jorgee!\desktop\uade\program. 1\proyectos\tp3-matrices\ejercicio 2\main.c 46 1 Ejercicio 2

I’ve included stdlib and time libraries.

Thanks a lot for the help.

/* 2.   Realizar una función que determine si una matriz cuadrada de dimensión N 
es simétrica con respecto a su diagonal principal. */


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>

#define FIL 5
#define COL 5

int True_False( char *message );
int Auto_Complete_Matrix( int matrix[ FIL ][ COL ] );
int Manual_Complete_Matrix( int matrix[ FIL ][ COL ] );
void Print_Matrix( int matrix[ FIL ][ COL ] );

int main () {
    int matrix[ FIL ][ COL ];
    if( True_False( "Desea autocompletar la Matriz con números al azar? <Si / No> \n\n" ) ) {
        Auto_Complete_Matrix( matrix );
    }
    else {
        Manual_Complete_Matrix( matrix );
    }
    Print_Matrix( matrix );
    system( "pause" );
}

int True_False( char *message ) {
    char Answer[3];
    fputs( message, stdout );
    fgets( Answer, 3, stdin );
    if ( Answer[0] == 1 ) {
        return 1;
    }
    if ( strncmp( Answer, "Si", 2 ) == 0 || strncmp( Answer, "si", 2 ) ) {
        return 1;
    }
    return 0;
}

int Auto_Complete_Matrix ( int matrix[ FIL ][ COL ] ) {

    srand(time(0));
    int i, j;

    for ( i = 0; i < FIL; i ++ ) {
        for ( j = 0; j < COL; j ++ ) {
            matrix[i][j] = rand() % (100 - 0 + 1) + 0;
        }
    }
    return 0;
}

int Manual_Complete_Matrix( int matrix[ FIL ][ COL ] ) {

    int i, j;

    for ( i = 0; i < FIL; i++ ) {
        for ( j = 0; j < COL; j++ ) {
            while( fscanf( stdin, "%d", matrix[i][j] ) != 1 ) {
                fflush( stdin );
                continue;
            }
        }
    }
}

void Print_Matrix( int matrix[ FIL ][ COL ] ) {
    int i, j;
    for( i = 0; i < FIL; i++) {
        for( j = 0; j < COL; j++ ) {
            printf( "%5d", matrix[i][j] );
        }
        puts("\n");
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:07:53+00:00Added an answer on June 6, 2026 at 5:07 pm

    In a file compiled as C (instead of C++), you must declare all variables at the top of the enclosing scope (i.e. in this case the surrounding curly braces). Here, you’re calling a function (srand) before the ‘int i, j’ declaration statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code that does not work: public CartaoCidadao() { InitializeComponent();
i have piece of code that works fine on my local test server but
I have this piece of code, that it refuses to work without the !important
I have a piece of code (.NET4 C#) that should run in tight loop
I have a piece of code that uses Microsoft-specific extension to the C++: interface
I have a piece of code that works in a VS.C# project, but when
I have this piece of code that works fine in subsonic 2.2, I migrated
I have a piece of code that load a very big image in memory.
I have a piece of code that takes several rows from a database and
I have a piece of code that look similar to this: <xsl:choose> <xsl:when test=some_test>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.