How To Solve Declaration Syntax Error In C
Tips/Tricks Top Articles Beginner Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article or tip Post your Blog quick answersQ&A Ask a Question View Unanswered Questions View All Questions... C# questions Linux questions ASP.NET questions SQL questions VB.NET questions discussionsforums All Message Boards... Application Lifecycle> Running a Business Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript C / C++ / MFC> ATL / WTL / STL Managed C++/CLI C# Free Tools Objective-C and Swift Database Hardware & Devices> System Admin Hosting and Servers Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research Library CodeProject Stuff communitylounge Who's Who Most Valuable Professionals The Lounge The Insider News The Weird & The Wonderful The Soapbox Press Releases Non-English Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Ask a Question All Questions All Unanswered FAQ Declaration syntax error Rate this: Please Sign up or sign in to vote. See more: C++ Q1)Design a class student containing getdata() and displaydata()as two of its methods which will be used for reading and displaying the student information respectively getdata() will be a private method? Is my code correct according to question? (I am not able to solve the declaration syntax error in void main() part) CODE:- #include class student { int rollno; char name; char stream; void getdata(int R,char N,char S) { rollno=r; name=N; stream=S; } public: void displaydata() { cout<<"Information \n"; } }; void main() { student s1 { cout<<"Student s1:"; } s1.getdata(112,Rahul,Science); s1.displaydata(); student s2 { cout<<"Student s2: "; } s2.getdata(113,sam,Arts); s2.displaydata(); } [edit]Code blocks added, indentation tidied, SHOUTING removed - OriginalGriff[/edit] Posted 23-Jul-11 22:45pm Brij2010361 Updated 24-Jul-11 7:13am Sergey Alexandrovich Kryukov1.1M v3 Add a Solution 5 solutions T
& Humanities Beauty & Style Business & Finance Cars & Transportation Computers & Internet Consumer Electronics Dining Out Education & Reference Entertainment & Music Environment Family & Relationships Food & Drink Games & Recreation Health Home & Garden Local Businesses News & Events Pets Politics & Government Pregnancy & Parenting Science & Mathematics Social Science Society & Culture Sports Travel Yahoo Products International Argentina Australia Brazil Canada France Germany Indonesia Italy Malaysia Mexico New Zealand Philippines Quebec Singapore Taiwan Hong Kong Spain Thailand UK & Ireland United States Vietnam Espanol About About Answers Community Guidelines Leaderboard Knowledge Partners Points & Levels Blog Safety Tips Computers & Internet Programming & Design Next Im http://www.codeproject.com/Questions/230441/Declaration-syntax-error getting declaration syntax error in function main() in C programming pl assist? my program is:- #include #include void main() { clrscr(); int a=10 printf("\nNumber :-%d",a); printf("\nNumber :-%d",++a); printf("\nNumber :-%d",a); printf("\nNumber :-%d",a++); printf("\nNumber :-%d",a); } Follow 3 answers 3 Report Abuse Are you sure that you want to delete this answer? Yes No Sorry, something has gone wrong. Trending Now Answers Relevance Rating Newest Oldest Best Answer: https://in.answers.yahoo.com/question/index?qid=20130223225647AABBDbx No semi colon after a=10 Source(s): Damianek · 4 years ago 0 Thumbs up 1 Thumbs down Comment Add a comment Submit · just now Report Abuse The main problem is a missing semi-colon (;) in the line int a=10 it should be int a=10; However, conio.h and clrscr() are not part of standard ANSI C. If you are using a Windows based C compiler then these might be available to use, as Windows (and DOS) have some limitiations that require conio.h and the functions it defines to do some of the things that are possible in a UNIX/Linux system without using these non-ANSI extensions. Finally, personally I would change the last print statement to be: printf("\nNumber :-%d\n",a); If you are running the program in a command line environment, adding "\n" at the end of the format will throw the next command prompt on to a new line rather than having it appear on the end of the final line of the output of the program.. Richard · 4 years ago 0 Thumbs up 1 Thumbs down Comment Add a comment Submit · just now Report Abuse Conio.h is not part of the standard C library
Programming Boards C Programming Need some help to fix a declaration syntax error Getting started with C or C++ | C Tutorial | C++ http://cboard.cprogramming.com/c-programming/145774-need-some-help-fix-declaration-syntax-error.html Tutorial | C and C++ FAQ | Get a compiler | Fixes for common problems Thread: Need some help to fix a declaration syntax error Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 02-06-2012 #1 Rob31645 View Profile View Forum Posts Registered User Join Date Feb 2012 Location Hawthorne, California, how to United States Posts 9 Need some help to fix a declaration syntax error I am new to programming and am trying to finish this project for my class. not sure where my error is here, can someone help point it out Code: #include #include #include int displayMenu(); int getData(int * a, int n); void input(); void display(); float mean1(float[],int); float median1(float[],int); float mode1(float[],int); how to solve double standarddeviation1(float array[],int n) int main() { int com; srand(time(NULL)); do{ com=displayMenu(); switch (com) { case 1 : input(); break; case 2 : display(); break; case 3 : printf("have a nice day\n");break; default : printf("Bad data Try again\n"); } }while(com !=3); return 0; } int displayMenu() { int c; printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); printf("@ 1. Enter data @\n"); printf("@ 2. Display data @\n"); printf("@ 3. Quit @\n"); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); printf("Enter your choice:"); scanf("%d",&c); return c ; } void input() { int i,n,choice; float array[200],mean,median,mode; double standarddeviation; switch(choice) { case 1: mean=mean1(array,n); printf("\n\tMean = %f\n",mean); break; case 2: median=median1(array,n); printf("\n\tMedian = \n",median); break; case 3: mode=mode1(array,n); printf("\n\tMode = %f\n",mode); break; case 4: standarddeviation=standarddeviation1(array,n); printf("\n\tStandard deviation = %f\n",standarddeviation); break; case 5: break; default:printf("Wrong Option"); break; } while(choice!=5); getchar(); return 0; } int getData(int * a, int n) { int i; i=n; printf("Enter item#%d>>",i+1); while(scanf("%d",&a[i])!=EOF) { i++; printf("Enter item#%d>>",i+1); } return i; } void display() { printf("is not done\n"); } float mean1(float array[],int n) { int i; float sum=0; for(i=0;i=0;i--) for(j=0;j=array[j+1]) { temp=array[j]; array[j]=array[j+1]; array[j+1]=temp; } if(n%2==0) return (array[n/2]+array[n/2-1])/2; else return array[n/2]; } float mode1(float a