473,386 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Expression syntax in function

while compiling this program it gives a syntax error saying "expression syntax in function add" in line no. 96. Kindly help.
#include<stdio.h>
int q[20],top=-1,front=-1,rear=-1,a[20][20],vis[20],stack[20];
int delete();
void add(int item);
void bfs(int n,int s);
void dfs(int n,int s);
void push(int item);
int pop();
main()
{
int n,i,s,ch,j;
char c,dummy;
printf("\nenter the number of vertices:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
printf("\enter 1 if %d has a node with %d else o:",j,i);
scanf("%d",a[i][j]);
}
}
printf("\nthe adjacency matrix is:");
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
printf("\n%d",a[i][j]);
}
printf("\n");
}
do
{
for(i=1;i<=n;i++)
vis[i]=0;
printf("MENU");
printf("\n1.B.F.S");
printf("\n2.D.F.S");
printf("\nenter your choice:");
scanf("%d",&ch);
printf("\nenter the source vertex:");
scanf("%d",&s);
switch(ch)
{
case 1:bfs(s,n);
break;
case 2:dfs(s,n);
break;
}
printf("\ndo you want to continue(Y/N)?");
scanf("%d",&dummy);
scanf("%c",&c);
}
while((c=='y')||(c=='Y'));
}
void bfs(int s,int n)
{
int p,i;
add(s);
vis[s]=1;
p=delete();
if(p!=0)
printf("\n%d");
while(p!=0)
{
for(i=1;i<=n;i++)
if((a[p][i]!=0)||(vis[i]==0))
{
add(i);
vis[i]=1;
}
p=delete();
if(p!=0)
printf("\n%d",p);
}
for(i=1;i<=n;i++)
if(vis[i]==0)
bfs(i,n);
}
void add(int item)
{
if(rear==19)
printf("\nqueue full");
else
{
if(rear==-1)
{
q[++rear]=item;
front++;
}
else
{
q[++rear]=item;
}
}
int delete()
{
int k;
if((front>rear)||(front==-1))
return(0);
else
{
k=q[front++];
return(k);
}
}
void dfs(int n,int s)
{
int k;
push(s);
vis[i]=1;
k=pop();
if(k!=0)
printf("\n%d",k);
while(k!=0)
{
for(i=1;i<=n;i++)
if((a[k][i]!=0))||(vis[i]==0))
{
push(i);
vis[i]=1;
}
k=pop();
if(k!=0)
printf("\n%d",k);
}
for(i=1;i<=n;i++)
if(vis[i]==0)
dfs(i,n);
}
void push(int item)
{
if(top==19)
printf("\nstack overflow");
else
stack[++top]=item;
}
int pop()
{
int k;
if(top==-1)
return(0);
else
{
k=stack[top--];
return(k);
}
}
}
Mar 25 '17 #1
2 1353
donbock
2,426 Expert 2GB
It is hard to tell from this listing but it looks like function add() is missing a closing brace }.

It helps when you enclose your source code in Code tags using the [CODE/] button.
Mar 25 '17 #2
weaknessforcats
9,208 Expert Mod 8TB
This code:

Expand|Select|Wrap|Line Numbers
  1. p = delete();
will never compile because delete is a C++ keyword. You are not allowed to have a function with the same name as a C++ keyword. Therefore, rename your delete function to something else.
Mar 25 '17 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: Tim Marsden | last post by:
Hi, Can you tell me the regular expression syntax needed to validate an Excel Cell Reference. e.g. A1, B1200, IV54000 etc Thank Tim
1
by: Sreedhar Vankayala | last post by:
Hi, I have a simple textbox in a form page. - If data not available, then user can enter the text "Not available" or "Contact abc person". - If data is available, then user enters the data...
4
by: clintonG | last post by:
I'm not getting the hang of what I thought I already understood. Maybe burnout? I want to build a string in code and write it into the HTML for display... // initiliazed in code string someText...
7
by: Hexer | last post by:
Hi and good day to all...I am new to the C language and whenever I tried to run the program I made, it won't because it says it has an "expression syntax error in function main"..what I don't get is...
3
by: seberino | last post by:
How similar is Python's re module (regular expressions) compared to Perl's and grep's regular expression syntaxes? I really hope regular expression syntax is sufficiently standardized that we...
1
by: AAaron123 | last post by:
I found this on the Internet and tried a few of them and they worked in VS2008. Actually it was in a different form but I converted to make a smaller file. The data is the same as the original. ...
2
by: sindhuja p | last post by:
i wrote a program on implementation of stacks using functions (data structures )...but i got expression syntax error in function main...........please help me out
1
by: Atl49anta | last post by:
im a newbie in c programming can somebody help me expression syntax error in cpp 10 #include<stdio.h> #include<conio.h> void main() { clrscr();
2
by: Chawwa94 | last post by:
Hi! I'm new to coding and today I tried to type a code to calculate the electricity bill. And I get this Expression Syntax error in line 56 and 68. Can anybody help me? Thank you. This is my code ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.