Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8349625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:03:53+00:00 2026-06-09T08:03:53+00:00

Help, I can’t seem to identify the problem in my code below. Here’s what

  • 0

Help, I can’t seem to identify the problem in my code below.

Here’s what I am trying to do: Input a list of marks. Input ends with 0 (0 itself is not someone’s mark). Output the number of students who scored
1) greater than or equal to 85;
2) between 60 and 84;
3) strictly less than 60.

Here’s my code:

#include stdio.h

int main() {
    int mark;
    int morethan85 = 0, between60and84 = 0, lessthan60 = 0;

    for (true) {
        scanf("%d", &mark);
        if (mark != 0) {
            if (mark >= 85)
                morethan85 = morethan85 + 1;
            else if (mark < 85 && mark >= 60)
                between60and84 = between60and84 + 1;
            else
                lessthan60 = lessthan60 + 1;
        } else
            break;
    }

    printf(">=85:%d, morethan85");
    printf("60-84:%d, between60and84");
    printf("<60:%d, lessthan60");

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:03:55+00:00Added an answer on June 9, 2026 at 8:03 am

    Whoah. Lots of stuff to comment here.

    1. First of all, “true” is not valid C. You can define a macro or constant named TRUE and set it to “1” – or simply use 1.

    2. If you are looping through something until it breaks, use while() and not for().

    3. Finally, the reason your code isn’t working is because you have you have added the quote symbol after the name of your variables in your printf() functions.

    Here is a working version of your code:

    #include <stdio.h>
    
    int main() {
        int mark;
        int morethan85 = 0;
        int between60and84 = 0;
        int lessthan60 = 0;
    
        while (1) {
            scanf("%d", &mark);
            if (mark != 0) {
                if (mark >= 85)
                    morethan85 ++;
                else if (mark < 85 && mark >= 60)
                    between60and84 ++;
                else
                    lessthan60 ++;
            } else
                break;
        }
    
        printf(">=85:%d\n", morethan85);
        printf("60-84:%d\n", between60and84);
        printf("<60:%d\n", lessthan60);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can help me in simple code below?? i commented where problem is TIA for(int
Who can help me to fix the following problem? Here is the issue: in
Anyone can help me? Trying to Add a Slow function with my smoothscroll and
Hopefully someone can help here, it's incredibly frustrating! I have a couple of iOS
Hopefully somebody can help me out here. I'm working within an embedded ActionScript2 and
Anyone can help me with this statement? I'm trying to get amount of beads
Hoping someone can help me design this correctly. In my TCP code, I have
Hopefully somebody can help me out here. I have a UIView with 3 text
Help I can't pass my hash key to twig subroutine. here: foreach my $word
Help I can't pass my hash key to twig subroutine. here: foreach my $word

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.