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 6551141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:18:00+00:00 2026-05-25T12:18:00+00:00

I have a friend who was working on a c example from a book

  • 0

I have a friend who was working on a c example from a book and he did a code like

#include<stdio.h>
#include<math.h>
#pragma warning(disable:4996)

int main()
{
    float numGrade;

    printf("\n\nPlease enter your numerical grade: ");
    scanf("%f", &numGrade);

    if (numGrade >= 90)
        printf("\nYou got an A.\n\n");
    else if (90 > numGrade >= 80)
        printf("\nYou got a B.\n\n");
    else if (80 > numGrade >= 70)
        printf("\nYou got a C.\n\n");
    else if (70 > numGrade >= 60)
        printf("\nYou got a D.\n\n");
    else if (60 > numGrade)
        printf("\nYou got an F.\n\n");
    else
        printf("\nThis is an invalid grade!\n");
}

Is there any problem with doing it like that or should he do it like :

int main()
{
    float numGrade;

    printf("\n\nPlease enter your numerical grade: ");
    scanf("%f", &numGrade);

    if (numGrade >= 90)
        printf("\nYou got an A.\n\n");
    else if (90 > numGrade && numGrade >= 80)
        printf("\nYou got a B.\n\n");
    else if (80 > numGrade && numGrade >= 70)
        printf("\nYou got a C.\n\n");
    else if (70 > numGrade && numGrade >= 60)
        printf("\nYou got a D.\n\n");
    else if (60 > numGrade)
        printf("\nYou got an F.\n\n");
    else
        printf("\nThis is an invalid grade!\n");
}
  • 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-05-25T12:18:00+00:00Added an answer on May 25, 2026 at 12:18 pm

    That first example won’t work at all.

    The first comparison in each test will return either 0 or 1. So it will always fail the second.

    EDIT:

    However, the program will probably still “work” the way it is desired, simply because the second comparison in each test is not needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a friend who has code like this in his wordpress files: Blockquote
This is an odd question. I have a friend who is working on an
I have a friend who was handed off a C#/.NET web project from a
I have a friend who did the same thing with window form. What I
I have a friend who is need of a web page. He does interior
I have a friend who is finishing up his masters degree in aerospace engineering.
I have a friend who I am trying to teach how to program. He
I have a friend who is trying to make the switch to Linux, but
I have a friend who is using c# Linq to report on the following
I have a good friend (my old college roommate, actually), who critiques my personal

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.