syntax error in DEV c++

This is a discussion on syntax error in DEV c++ within the C Programming forums, part of the General Programming Boards category; ok this is not my code put one of the guys i am in group with. his error is on ...

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    18

    syntax error in DEV c++

    ok this is not my code put one of the guys i am in group with.

    his error is on the last bracet could some one help us out as what to look at all the things I have learned from all of you.

    Code:
    #include <stdio.h>
    #include <string.h>
    
       int main(int argc, char *argv[])
    {
    
        char studname[30];
        int grade=0;
        int assignment=0;
        int gradeavg=0;
      
        do
        {
         printf("What is the student's name? ");
         scanf("%s",studname);
        
         for(assignment=1;assignment<=5;assignment++)  //getting grades 1-5
             {
             printf("What is the score for %s's assignment #%d?",studname,assignment);
             scanf("%d",&grade);
             gradeavg=gradeavg+grade;
             }
        while(strcmp(studname,"bye")==0);//ending loop when studname is "bye"
                 {
                 gradeavg=gradeavg/5;
                 printf("%s's average is %d. \n",studname,gradeavg);//printing gradeavg
                 }
        
      system("PAUSE");
      return (0); 
    }
    }
    }

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Postponing using good indentation bites another one...
    Code:
    int main(int argc, char *argv[])
    {
    
       char studname[30];
       int grade=0;
       int assignment=0;
       int gradeavg=0;
    
       do
       {
          printf("What is the student's name? ");
          scanf("%s",studname);
    
          for ( assignment=1;assignment<=5;assignment++ )  //getting grades 1-5
          {
             printf("What is the score for %s's assignment #%d?",studname,assignment);
             scanf("%d",&grade);
             gradeavg=gradeavg+grade;
          }
          while ( strcmp(studname,"bye")==0 );//ending loop when studname is "bye"
          {
             gradeavg=gradeavg/5;
             printf("%s's average is %d. \n",studname,gradeavg);//printing gradeavg
          }
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396
    Yuck, the indentation is horrid!

    Try lining up your opening and closing baces! This will probably help you out!

    /edit.
    Finally got my attachment included.
    Attached Images Attached Images  
    Last edited by Bajanine; 01-15-2006 at 09:06 PM. Reason: Beat again!
    Favorite Quote:

    >For that reason someone invented C++.
    BLASPHEMY! Begone from my C board, you foul lover of objects, before the gods of C cast you into the void as punishment for your weakness! There is no penance for saying such things in my presence. You are henceforth excommunicated. Never return to this house, filthy heretic!



Popular pages Recent additions subscribe to a feed

Similar Threads

  1. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 06:33 AM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21