473,396 Members | 1,768 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,396 software developers and data experts.

error:expression syntax in function main

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. int maxi(int x,int y);
  3. int buildtourn(int tourn[],int n);
  4. int nextmax(int tourn[],int n);
  5.  
  6. int main()
  7. {
  8. int tourn[100],n,i;
  9. printf("give n:");
  10. scanf("%d",&n);
  11. for(i=n;i<2*n-1;i++)
  12. {printf("give the %d inputs",n);
  13. scanf("%d",&tourn[i]);
  14. }
  15. printf("%d",nextmax(tourn[],n));
  16. printf("maximum is %d",tourn[1]);
  17.  
  18. return 0;
  19. }
  20. int buildtourn(int tourn[],int n)
  21. {int i;
  22. for(i=2*n-1;i>1;i-=2)
  23. tourn[i/2]=maxi(tourn[i],tourn[i+1]);
  24. return 0;
  25. }
  26. int nextmax(int tourn[],int n)
  27. {int i=2,next;
  28. next=maxi(tourn[2],tourn[3]);
  29. while(i<=2*n-1)
  30. {
  31. if(tourn[i]>tourn[i+1])
  32. {next=maxi(tourn[i],next);
  33. i=2*i;
  34. }
  35. else
  36. {next=maxi(tourn[i+1],next);
  37. i=2*(i+1);} }
  38. return(next);}
Sep 25 '11 #1
1 2659
johny10151981
1,059 1GB
your error on line 15,
if you want to pass the pointer to
Expand|Select|Wrap|Line Numbers
  1. nextmax
function then this is a wrong way, try this

Expand|Select|Wrap|Line Numbers
  1. printf("%d",nextmax(&tourn[0],n))
  2.  
Sep 26 '11 #2

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

Similar topics

4
by: Jeremy Yallop | last post by:
Looking over some code I came across a line like this if isalnum((unsigned char)c) { which was accepted by the compiler without complaint. Should the compiler have issued a diagnostic in this...
8
by: Rody Reulen | last post by:
I made an console application with Visual Basic .net. Visual Basic will automatically create the sub procedure main for you. I try to convert the main procedure to a function. During the...
1
by: joe10001 | last post by:
Hi all, I just installed CRELoaded (oscommerce fork) on my server and all work fine except that I have a little message at the bottom of the main page : Fatal error: main() : Security alert:...
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...
4
by: huggsy | last post by:
I started using C just today and I am having a problem with strrev() function. Here are my codes: #include<stdio.h> #include<conio.h> #include<string.h> main()
3
by: ANURAGBAJPAI | last post by:
Please tell me what is the purpose of void in function main.
2
by: ehab mohamed | last post by:
When i try to run this program it give me a message that Lvalue required in function main. What is the cause?
0
by: pecca | last post by:
this is sample of my program #include<iostream.h> #include<conio.h> #define n 5 int total(int number); int average(int average, int total); void min_max(int number,int &min,int &max); void...
1
by: DavidSS | last post by:
Okay, I have a problem. I just started programming, and made my first "calculator" I then started making it more advanced, so it wouldn't crash if you tried to divide by 0. Then I wanted to make...
5
by: ehab mohamed | last post by:
#include<stdio.h> int main() { typedef struct { char name; int salary; }me; me a; a.name="ehab"; a.salary=5789;
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.