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

  • SEARCH
  • Home
  • 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 7857937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:11:57+00:00 2026-06-02T21:11:57+00:00

this is prog in C (adjacency.c) that checks if exists in directed graph way

  • 0

this is prog in C (adjacency.c) that checks if exists in directed graph way from node a to node b

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

#define N 11
#define FALSE 0
#define TRUE 1

typedef  int[N][N] adj_mat;

int path (adj_mat A, int u, int v)





    
void main()
    {
        adj_mat Matrix; 
        int dadnode, sonnode; 

        printf("bla-bla-bla enter nodes.\n");            
             printf("Press Ctrl+Z after finishing  of bla-bla-bla all the nodes\n");
        
        do {    
            printf("Enter the  number of first node\n"); 
            scanf("%d", &dadnode);
            printf("Enter the  number of second node\n");
            scanf("%d", &sonnode;);

            if ((dadnode < sonnode) && (sonnode <= N) && (dadnode > 0)) 
                Matrix[dadnode][sonnode] = 1; 
            } while ( (dadnode != EOF ) && (sonnode != EOF)); 


        printf("Now enter u and v nodes to check if exists way from u node to we node\n")
                        
            printf("Enter the  number of u node\n"); 
            scanf("%d", &dadnode);
            printf("Enter the  number of v node\n");
            scanf("%d", &sonnode;);

            if ((dadnode < sonnode) && (sonnode <= N) && (dadnode > 0)) 
             {
                if(path(Matrix,dadnode,sonnode) == TRUE ) 
                    printf ("Exists way from node u to node v ");   
             }
             
                else printf printf ("Not exists way from node u to node v ");   

    }






int path (adj_mat A, int u, int v) 
    {
        if (v >= u)  
        return FALSE; 

        int nodenum; 

        for(nodenum = v - 1; nodenum > 0; nodenum-- ) 
                                                          
            {
                if (A[nodenum][v] == TRUE) 
                {
                    if (nodenum == u) /
                        return TRUE;

                    else if (path (adj_mat A, int u, int nodenum)) 
                                                
                                
                        return TRUE;
                }
            }   
            
        return FALSE; 
    }

when i type command

gcc -o adjacency -ansi adjacency.c

i get

adjacency.c:8: error: expected identifier or ‘(’ before ‘[’ token

adjacency.c:10: error: expected ‘)’ before ‘A’

adjacency.c:58: error: expected ‘)’ before ‘A’

how to fix ?

update: thanks to all for help. compiled.

  • 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-02T21:11:59+00:00Added an answer on June 2, 2026 at 9:11 pm

    You should move the [N][N] part to the end of the declaration, and add a semicolon after the forward declaration of path.

    typedef  int adj_mat[N][N];
    int path (adj_mat A, int u, int v);
    

    There are also inaccuracies in the remaining of your code:

    • scanf("%d", &sonnode;); has extra semicolon, should be scanf("%d", &sonnode);
    • else printf printf should be else printf
    • Semicolons are missing in a few places
    • a / is at the end of one line that shouldn’t be there
    • main needs to return an int
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I compile my simple prog with #include <sys/socket.h> but there's none of this file.
I have the below prog Object.prototype.inherit = function(baseConstructor) { this.prototype = (baseConstructor.prototype); this.prototype.constructor =
//deep linking $.fn.ajaxAnim = function() { $(this).animW(); $(this).html('<div class=load-prog>loading...</div>'); } $(document).ready(function(){ contM = $('#main-content');
I have this prog, just a skeleton for a simple sever and client connection.
Python optparse works very good when script usage is something like this %prog [options]
Very strange situation. check this out : billy@prog:~/sql$ grep -R temp_exchange *.sp billy@prog:~/sql$ grep
Well, I have a header (my_prog.h) which looks like this: #ifndef __MY_HEADER_H #define __MY_HEADER_H
I have a piece of javascript code like this if(prog > 100) prog =
Im using StructureMap for IoC, im getting Configuration from App.Config, like this: public class
I wrote this function that uses a binary search to look for a specific

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.