Thread: Cprogram for grades.....pls help

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    13

    Post Cprogram for grades.....pls help

    input
    .grade
    .equivalent
    .remarks

    output
    ...grade
    ...equivalent remarks
    1- 95- 91
    2- 90-86
    3- 85-81
    4 80-76
    5- 75-70
    above 95 notin range
    below 69 mot in range



    ......remarks passed or failed
    75-95 passed
    74-70 failed

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Announcements - C Programming
    You need to show some minimal effort first.
    At least you should know enough printf/scanf to be able to input all the data and print it back out again.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You should describe your requirements in words more clearly, show us what you have tried and tell us how does it not work.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Nov 2012
    Posts
    13
    Code:
    #include<stdio.h>
    #define s scanf
    #define p printf
    
    main()
    {
        char fn[25],sn[25];
        char tf[25],sf[25];
        char sec[25],sub[25];
        float gr;
        char answer;
    
        clrscr();
    
    
    
            p("Enter your Name: ");
            s("%s %s",&fn,sn);
    
            p("Enter your Section: ");
            s("%s",&sec);
    
            p("Enter your Subject: ");
            s("%s",&sub);
    
            p("Enter Name of your teacher: ");
            s("%s %s ",&tf,sf);
    
            p("Enter your Grade:");
            s("%f",&gr);
    
            clrscr();
        do
        {
            if (95>=gr && gr>=91)
            {
                p("Student Name: %s %s\n",fn,sn);
                p("Section: %s\n",sec);
                p("Subject: %s\n",sub);
                p("Teacher Name: %s %s\n",tf,sf);
                p("Grade : %0.f\n",gr);
                p("Equivalent Remarks: 1\n");
                p("REMARKS: PASSED \n");
            }
    
            else if (90>=gr || gr>=86)
            {
                p("Student Name: %s %s\n",fn,sn);
                p("Section: %s\n",sec);
                p("Subject: %s\n",sub);
                p("Teacher Name: %s %s\n",tf,sf);
                p("Grade : %0.f\n",gr);
                p("Equivalent Remarks: 2\n");
                p("REMARKS: PASSED \n");
            }
    
    
            else if (gr<=85 || gr>=81)
            {
                p("Student Name: %s %s\n",fn,sn);
                p("Section: %s\n",sec);
                p("Subject: %s\n",sub);
                p("Teacher Name: %s %s\n",tf,sf);
                p("Grade : %0.f\n",gr);
                p("Equivalent Remarks: 3\n");
                p("REMARKS: PASSED \n");
            }
    
    
            else if (gr<=80 || gr>=76)
            {
                p("Student Name: %s %s\n",fn,sn);
                p("Section: %s\n",sec);
                p("Subject: %s\n",sub);
                p("Teacher Name: %s %s\n",tf,sf);
                p("Grade : %0.f\n",gr);
                p("Equivalent Remarks: 4\n");
                p("REMARKS: PASSED \n");
            }
    
    
            else if (gr<=75 || gr>=70)
            {
               if (gr>=70 || gr<75)
                {
                p("Student Name: %s %s\n",fn,sn);
                p("Section: %s\n",sec);
                p("Subject: %s\n",sub);
                p("Teacher Name: %s %s\n",tf,sf);
                p("Grade : %0.f\n",gr);
                p("Equivalent Remarks: 5\n");
                p("REMARKS: FAILED \n");
                }
                else
                {
                p("Student Name: %s %s\n",fn,sn);
                p("Section: %s\n",sec);
                p("Subject: %s\n",sub);
                p("Teacher Name: %s %s\n",tf,sf);
                p("Grade : %0.f\n",gr);
                p("Equivalent Remarks: 5\n");
                p("REMARKS: PASSED \n");
                 }
            }
            else
            {
                p("Student Name: %s %s\n",fn,sn);
                p("Section: %s\n",sec);
                p("Subject: %s\n",sub);
                p("Teacher Name: %s %s\n",tf,sf);
                p("Grade : %0.f\n",gr);
                p("Equivalent Remarks: Not in Range\n");
                p("REMARKS: Not in Range \n");
             }
    
            clrscr();
    
        p("Would your like to try again? [y/n]");
        answer=getch();
        }
        while (answer=='Y' || answer=='y');
        exit();
        getch();
    
    getch();
    }
    --this is not working--

    example
    if grade was 95 the
    grade:95
    equvalent: 5
    remarks: passed

    if grade was 74 the
    grade:74
    equvalent: 5
    remarks: failed

    if grade was 96 the
    grade:96
    equvalent: nto in range
    remarks: not in range

  5. #5
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Well you might want to start fixing the following warnings and errors:
    Code:
    mingw32-gcc.exe -Wall  -g  -pedantic -Wextra -Wall -g    -c C:\Users\Josh2\Documents\bar\main.c -o obj\Debug\main.o
    C:\Users\Josh2\Documents\bar\main.c:5:1: warning: return type defaults to 'int' [-Wreturn-type]
    C:\Users\Josh2\Documents\bar\main.c: In function 'main':
    C:\Users\Josh2\Documents\bar\main.c:13:5: warning: implicit declaration of function 'clrscr' [-Wimplicit-function-declaration]
    C:\Users\Josh2\Documents\bar\main.c:18:9: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[25]' [-Wformat]
    C:\Users\Josh2\Documents\bar\main.c:21:9: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[25]' [-Wformat]
    C:\Users\Josh2\Documents\bar\main.c:24:9: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[25]' [-Wformat]
    C:\Users\Josh2\Documents\bar\main.c:27:9: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[25]' [-Wformat]
    C:\Users\Josh2\Documents\bar\main.c:119:5: warning: implicit declaration of function 'getch' [-Wimplicit-function-declaration]
    C:\Users\Josh2\Documents\bar\main.c:122:5: warning: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
    C:\Users\Josh2\Documents\bar\main.c:122:5: warning: incompatible implicit declaration of built-in function 'exit' [enabled by default]
    C:\Users\Josh2\Documents\bar\main.c:122:5: error: too few arguments to function 'exit'
    C:\Users\Josh2\Documents\bar\main.c:126:1: warning: control reaches end of non-void function [-Wreturn-type]
    Process terminated with status 1 (0 minutes, 0 seconds)
    1 errors, 10 warnings
    These are rather important errors that could contribute to it "not working".

    getch(), clrscr(), exit() ... do you even know where these functions come from? You need to include the relevant headers.

    #define s scanf
    #define p printf

    You do not understand how hard I want you to hit the delete key for these two statements. I want you to hit it so hard, that can't be typed ever again in that particular arrangement.

    I l I d t w a w s w o c.
    (It's like I decided to write a whole sentence with one character)

  6. #6
    Registered User
    Join Date
    Nov 2012
    Posts
    13
    Code:
    #include<stdio.h>
    #define s scanf
    #define p printf
    
    main()
    {
        char fn,sn;
        char tf,sf;
        char sec,sub;
        float gr;
    
        clrscr();
    
        do
        {
            p("Enter your Name: ");
            s("%s %s ",&fn,sn);
            
            p("Enter your Section: ");
            s("%s",&sec);
    
            p("Enter your Subject: ");
            s("%s",&sub);
    
            p("Enter Name of your teacher: ");
            s("%s %s ",&tf,ts);
    
            p("Enter your Grade:");
            s("%f",&gr);
    
            clrscr();
    
            If (gr=<95 || gr>=91)
            {
                p("Student Name: %s %s\n",fn,sn);
                p("Section: %s\n",sec);
                p("Subject: %s\n",sub);
                p("Teacher Name: %s %s\n",tf,ts);
                p("Grade : %0.f\n",gr)
                p("Equivalent Remarks: 1\n");
                p("REMARKS: PASSED \n");
            }
    
            else if (gr=<90 || gr>=86)
            {
                p("Student Name: %s %s\n",fn,sn);
                p("Section: %s\n",sec);
                p("Subject: %s\n",sub);
                p("Teacher Name: %s %s\n",tf,ts);
                p("Grade : %0.f\n",gr)
                p("Equivalent Remarks: 2\n");
                p("REMARKS: PASSED \n");
            }
    
    
            else if (gr=<85 || gr>=81)
            {
                p("Student Name: %s %s\n",fn,sn);
                p("Section: %s\n",sec);
                p("Subject: %s\n",sub);
                p("Teacher Name: %s %s\n",tf,ts);
                p("Grade : %0.f\n",gr)
                p("Equivalent Remarks: 3\n");
                p("REMARKS: PASSED \n");
            }
    
    
            else if (gr=<80 || gr>=76)
            {
                p("Student Name: %s %s\n",fn,sn);
                p("Section: %s\n",sec);
                p("Subject: %s\n",sub);
                p("Teacher Name: %s %s\n",tf,ts);
                p("Grade : %0.f\n",gr)
                p("Equivalent Remarks: 4\n");
                p("REMARKS: PASSED \n");
            }
    
    
            else if (gr=<75 || gr>=70)
            {
               if (gr>=70 || gr<75)
                {
                p("Student Name: %s %s\n",fn,sn);
                p("Section: %s\n",sec);
                p("Subject: %s\n",sub);
                p("Teacher Name: %s %s\n",tf,ts);
                p("Grade : %0.f\n",gr)
                p("Equivalent Remarks: 5\n");
                p("REMARKS: FAILED \n");
                }
                else
                {
                p("Student Name: %s %s\n",fn,sn);
                p("Section: %s\n",sec);
                p("Subject: %s\n",sub);
                p("Teacher Name: %s %s\n",tf,ts);
                p("Grade : %0.f\n",gr)
                p("Equivalent Remarks: 5\n");
                p("REMARKS: PASSED \n");
                 }            
            }
            else 
            {
                p("Student Name: %s %s\n",fn,sn);
                p("Section: %s\n",sec);
                p("Subject: %s\n",sub);
                p("Teacher Name: %s %s\n",tf,ts);
                p("Grade : %0.f\n",gr)
                p("Equivalent Remarks: Not in Range\n");
                p("REMARKS: Not in Range \n");
             }
            
            clrscr();
            
        p("Would your like to try again? [y/n]")
        answer=getch();
        }
        while (answer=='Y' || anwer=='y')
        exit();
        getch();    
            
    getch();
    }

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    You might do better if you got rid of those stupid p/s macros for printf/scanf, and used more meaningful variable names like studentGrade instead of gr

    > if (95>=gr && gr>=91)
    This is unnecessarily confusing, when you then switch over to doing this
    > else if (gr<=85 || gr>=81)

    Ignore all the operand-swapping zealots (their advice is locked in the 1980's), and just write your expressions as you would say them in natural English.
    You would normally say
    if grade is less than or equal to 95

    You would never tell people
    if 95 is bigger than grade
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Concerning the code in #6 I would like to know if you even thought about what you did, or tried it. Because it should crash.

    scanf requires an address to store information from the user in, just like all versions of scanf. Now, since an array decays to a pointer to the first element, which contains said address, you do not need to use the & operator on a character array. The proper response was NOT to nerf all of your arrays, as if to get the program to work by magic.

  9. #9
    Registered User
    Join Date
    Nov 2012
    Posts
    13
    Code:
    #include<stdio.h>
    
    main()
    {
        char firstname,surname;
        char teachername,teachersurname;
        char section,subject;
        float grade;
    
        clrscr();
    
        do
        {
            printf("Enter your Name: ");
            scanf("%s %s ",&firstname,surname);
            
            printf("Enter your section ");
            scanf("%s",&section);
    
            printf("Enter your subject: ");
            scanf("%s",&subject);
    
            printf("Enter Name of your teacher: ");
            scanf("%s %s ",&teachername,ts);
    
            printf("Enter your grade:");
            scanf("%f",&grade);
    
            clrscr();
    
            If (95>=grade || grade>=91)
            {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("grade : %0.f\n",grade)
                printf("Equivalent Remarks: 1\n");
                printf("REMARKS: PASSED \n");
            }
    
            else if (grade=<90 || grade>=86)
            {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("grade : %0.f\n",grade)
                printf("Equivalent Remarks: 2\n");
                printf("REMARKS: PASSED \n");
            }
    
    
            else if (grade=<85 || grade>=81)
            {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("grade : %0.f\n",grade)
                printf("Equivalent Remarks: 3\n");
                printf("REMARKS: PASSED \n");
            }
    
    
            else if (grade=<80 || grade>=76)
            {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("grade : %0.f\n",grade)
                printf("Equivalent Remarks: 4\n");
                printf("REMARKS: PASSED \n");
            }
    
    
            else if (grade=<75 || grade>=70)
            {
               if (grade>=70 || grade<75)
                {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("grade : %0.f\n",grade)
                printf("Equivalent Remarks: 5\n");
                printf("REMARKS: FAILED \n");
                }
                else
                {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("Grade : %0.f\n",grade)
                printf("Equivalent Remarks: 5\n");
                printf("REMARKS: PASSED \n");
                 }            
            }
            else 
            {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("Grade : %0.f\n",grade)
                printf("Equivalent Remarks: Not in Range\n");
                printf("REMARKS: Not in Range \n");
             }
            
            clrscr();
            
        printf("Would your like to try again? [y/n]")
        answer=getch();
        }
        while (answer=='Y' || anwer=='y')
        exit();
        getch();    
            
    getch();
    }

  10. #10
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > printeachername("Teacher Name: %s %s\n",teachername,ts);
    Great - now change it to printf()
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  11. #11
    Registered User
    Join Date
    Nov 2012
    Posts
    13
    no display output!!!

  12. #12
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    No display?
    It doesn't even compile.
    Code:
    #include<stdio.h>
    
    int main()
    {
        char firstname,surname;
        char teachername,teachersurname;
        char section,subject;
        float grade;
    
    //    clrscr();
    
        do
        {
            printf("Enter your Name: ");
            scanf("%s %s ",&firstname,surname);
            
            printf("Enter your section ");
            scanf("%s",&section);
    
            printf("Enter your subject: ");
            scanf("%s",&subject);
    
            printf("Enter Name of your teacher: ");
            scanf("%s %s ",&teachername,ts);
    
            printf("Enter your grade:");
            scanf("%f",&grade);
    
    //        clrscr();
    
            if (95>=grade || grade>=91) //!! capitalised If
            {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("grade : %0.f\n",grade); //!! missing ;
                printf("Equivalent Remarks: 1\n");
                printf("REMARKS: PASSED \n");
            }
    
            else if (grade=<90 || grade>=86)
            {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("grade : %0.f\n",grade); //!! missing ;
                printf("Equivalent Remarks: 2\n");
                printf("REMARKS: PASSED \n");
            }
    
    
            else if (grade=<85 || grade>=81)
            {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("grade : %0.f\n",grade); //!! missing ;
                printf("Equivalent Remarks: 3\n");
                printf("REMARKS: PASSED \n");
            }
    
    
            else if (grade=<80 || grade>=76)
            {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("grade : %0.f\n",grade); //!! missing ;
                printf("Equivalent Remarks: 4\n");
                printf("REMARKS: PASSED \n");
            }
    
    
            else if (grade=<75 || grade>=70)
            {
               if (grade>=70 || grade<75)
                {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("grade : %0.f\n",grade); //!! missing ;
                printf("Equivalent Remarks: 5\n");
                printf("REMARKS: FAILED \n");
                }
                else
                {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("Grade : %0.f\n",grade); //!! missing ;
                printf("Equivalent Remarks: 5\n");
                printf("REMARKS: PASSED \n");
                 }            
            }
            else 
            {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("Grade : %0.f\n",grade); //!! missing ;
                printf("Equivalent Remarks: Not in Range\n");
                printf("REMARKS: Not in Range \n");
             }
            
            //clrscr();
            
        printf("Would your like to try again? [y/n]"); //!! missing ;
        answer=getchar(); //!! not getch
        }
        while (answer=='Y' || anwer=='y')
    //     exit();
    //     getch();    
    //         
    // getch();
        return 0; //!! added
    }
    
    
    $ gcc -Wall bar.c
    bar.c: In function ‘main’:
    bar.c:15:9: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
    bar.c:24:37: error: ‘ts’ undeclared (first use in this function)
    bar.c:24:37: note: each undeclared identifier is reported only once for each function it appears in
    bar.c:33:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:33:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
    bar.c:34:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:35:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:42:24: error: expected expression before ‘<’ token
    bar.c:44:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:44:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
    bar.c:45:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:46:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:54:24: error: expected expression before ‘<’ token
    bar.c:56:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:56:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
    bar.c:57:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:58:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:66:24: error: expected expression before ‘<’ token
    bar.c:68:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:68:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
    bar.c:69:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:70:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:78:24: error: expected expression before ‘<’ token
    bar.c:82:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:82:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
    bar.c:83:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:84:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:92:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:92:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
    bar.c:93:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:94:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:103:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:103:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
    bar.c:104:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:105:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
    bar.c:115:5: error: ‘answer’ undeclared (first use in this function)
    bar.c:117:27: error: ‘anwer’ undeclared (first use in this function)
    bar.c:122:5: error: expected ‘;’ before ‘return’
    bar.c:6:22: warning: unused variable ‘teachersurname’ [-Wunused-variable]
    bar.c:123:1: warning: control reaches end of non-void function [-Wreturn-type]
    Fix some variable names.
    Change some of your chars into char arrays (all those with warning: format ‘%s’ expects argument of type ‘char *’, )

    Given your other posts, it looks like you can't be bothered and are looking for an easy ride by trying to get someone else to do the work.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  13. #13
    Registered User
    Join Date
    Nov 2012
    Posts
    13
    Code:
    
    
    Code:
    #include<stdio.h>
     
    int main()
    {
        char firstname[25],surname[23];
        char teachername[12],teachersurname[21];
        char section,subject;
        float grade;
     
    //    clrscr();
     
        do
        {
            printf("Enter your Name: ");
            scanf("%s %s ",&firstname,surname);
             
            printf("Enter your section ");
            scanf("%s",&section);
     
            printf("Enter your subject: ");
            scanf("%s",&subject);
     
            printf("Enter Name of your teacher: ");
            scanf("%s %s ",&teachername,ts);
     
            printf("Enter your grade:");
            scanf("%f",&grade);
     
    //        clrscr();
     
            if (95>=grade || grade>=91) //!! capitalised If
            {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("grade : %.0f\n",grade); //!! missing ;
                printf("Equivalent Remarks: 1\n");
                printf("REMARKS: PASSED \n");
            }
     
            else if (grade=<90 || grade>=86)
            {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("grade : %.0f\n",grade); //!! missing ;
                printf("Equivalent Remarks: 2\n");
                printf("REMARKS: PASSED \n");
            }
     
     
            else if (grade=<85 || grade>=81)
            {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("grade : %.0f\n",grade); //!! missing ;
                printf("Equivalent Remarks: 3\n");
                printf("REMARKS: PASSED \n");
            }
     
     
            else if (grade=<80 || grade>=76)
            {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("grade : %.0f\n",grade); //!! missing ;
                printf("Equivalent Remarks: 4\n");
                printf("REMARKS: PASSED \n");
            }
     
     
            else if (grade=<75 || grade>=70)
            {
               if (grade>=70 || grade<75)
                {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("grade : %.0f\n",grade); //!! missing ;
                printf("Equivalent Remarks: 5\n");
                printf("REMARKS: FAILED \n");
                }
                else
                {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("Grade : %.0f\n",grade); //!! missing ;
                printf("Equivalent Remarks: 5\n");
                printf("REMARKS: PASSED \n");
                 }            
            }
            else
            {
                printf("Student Name: %s %s\n",firstname,surname);
                printf("section %s\n",section);
                printf("subject: %s\n",subject);
                printf("Teacher Name: %s %s\n",teachername,ts);
                printf("Grade : %.0f\n",grade); //!! missing ;
                printf("Equivalent Remarks: Not in Range\n");
                printf("REMARKS: Not in Range \n");
             }
             
            //clrscr();
             
        printf("Would your like to try again? [y/n]"); //!! missing ;
        answer=getchar(); //!! not getch
        }
        while (answer=='Y' || anwer=='y')
    //     exit();
    //     getch();    
    //         
    // getch();
        return 0; //!! added
    }

  14. #14
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Getting better (slowly) - KEEP AT IT!
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  15. #15
    Registered User
    Join Date
    May 2012
    Posts
    1,066
    Instead of continuing posting code which is full of errors I suggest to either ask specific questions or dump your garbage somewhere else.

    Bye, Andreas

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Cprogram Input/output parameter HELP
    By 123456tacos in forum C Programming
    Replies: 5
    Last Post: 03-11-2011, 10:59 PM
  2. Homework HELP! CProgram Electric Company
    By 123456tacos in forum C Programming
    Replies: 20
    Last Post: 03-04-2011, 10:33 PM
  3. Grades
    By ksample23 in forum C Programming
    Replies: 7
    Last Post: 04-01-2010, 08:20 AM
  4. Cprogram/Excel/Bargraph
    By friend in forum C Programming
    Replies: 3
    Last Post: 09-15-2003, 04:44 PM
  5. Replies: 13
    Last Post: 08-15-2002, 09:20 AM

Tags for this Thread