GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 14-Jul-2008, 10:09
begame begame is offline
New Member
 
Join Date: Jul 2008
Posts: 2
begame is on a distinguished road
Question

Help Expression Syntax


Hello!
I am learning c++ at school using compiler turbo c++ v3.0.I was to write a program with a structur CANDIDATE, with following members:
cno,score-int and cname-array [20].
I was to write a menu driven program with separte funcns for enterting value into array of candidate, displaying it,and sorting the array in ascending order pf Score using bubble sort

But in the line where i have used the fucntions and passed the actual parameters it gives me an "Expression Syntax" error in all the places i have used the fuctions.
Please help.

Thankyou
Digvijay

Code:
CPP / C++ / C Code:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>

struct CANDIDATE
{
  int Cno,Score;
  char Cname[20];
};

void IN(CANDIDATE A[],int sz)
{

  for(int i=0;i<sz;i++)
  {
    cout<<"Enter value into the "<<i<<"th element of array CANDIDATE"<<endl;
    cout<<"Enter Cno:";cin>>A[i].Cno;cout<<endl;
    cout<<"Enter Cname:";gets(A[i].Cname);cout<<endl;
    cout<<"Enter Score:";cin>>A[i].Score;cout<<endl;
  }
  cout<<"--------------------------------------------------"<<endl;
  getch();
}

void OUT(CANDIDATE A[],int sz)
{
  cout<<"Now displaying an array of CANDIDATE:"<<endl;
  for(int i=0;i<sz;i++)
  {
    cout<<A[i].Cno<<":"<<A[i].Cname<<":"<<A[i].Score<<endl;
  }
  cout<<"--------------------------------------------------"<<endl;
  getch();
}

void SORT(CANDIDATE A[],int sz)
{
  int flag=0,temp;
  cout<<"Now sorting the array of CANDIDATE in ascending order of Score...."<<endl;
  for(int i=0;i<sz && flag;i++)
  {
    flag=0;
    for(int j=0;j<sz;j++)
    {
      if(A[j].Score>A[j+1].Score)
      {
	temp=A[j].Score;
	A[j].Score=A[j+1].Score;
	A[j+1].Score=temp;
	flag=1;
      }
    }
  }
  cout<<"Sorting Complete!"<<endl<<"--------------------------------------------------"<<endl;
  getch();
}

void main()
{
  int ch,sz;
  CANDIDATE A[10];
  do
  {
  cout<<"Enter the size of the array <=10"<<endl;
  cin>>sz;
  }while(sz>10);
  do
  {
    cout<<"Enter your choice:\n1.Enter Values into CANDIDATE\n2.Display\n3.Sort CANDIDATE\n4.Exit"<<endl;
    cin>>ch;
    if(ch==1)
    {
      IN(A[],sz);//expression syntax error 1
      clrscr();
    }
    else if(ch==2)
    {
      OUT(A[],sz);clrscr();//expression syntax error 2
    }
    else if(ch==3)
    {
      SORT(A[],sz);clrscr();//expression syntax error 3
    }
  }while(ch!=4);
  cout<<"Thank You for using the program!"<<endl;
}
  #2  
Old 14-Jul-2008, 10:21
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 713
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: Help Expression Syntax


CPP / C++ / C Code:
//IN(A[],sz);//expression syntax error 1
IN(A,sz);
  #3  
Old 14-Jul-2008, 10:27
begame begame is offline
New Member
 
Join Date: Jul 2008
Posts: 2
begame is on a distinguished road

Re: Help Expression Syntax


Quote:
Originally Posted by fakepoo
CPP / C++ / C Code:
//IN(A[],sz);//expression syntax error 1
IN(A,sz);
O yes!
Thanks for your help!
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linked Lists advice request promsan C Programming Language 74 23-May-2007 09:29
syntax errors in document coder MS Visual C++ / MFC Forum 0 11-Mar-2006 05:12
Winsock error when compiling FLTK 2.0 Projects mauriciorossi FLTK Forum 3 16-Aug-2005 11:18
Help with syntax errors PeteGallo C Programming Language 7 08-Aug-2005 21:30
Can enum have same name as class? crystalattice C++ Forum 3 08-Dec-2004 17:43

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 02:11.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.