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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:12:35+00:00 2026-06-07T00:12:35+00:00

Sorry for this simple question, but I can’t solve it… There is an example:

  • 0

Sorry for this simple question, but I can’t solve it…

There is an example:

int a[10] = {6, 7.8, 8.0, -6, -5.7, 5, 5.7};

std::cout << a[6 % 8 / 4 + 21 % 9];

In response I get -5, but I don’t understand why.

  • 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-07T00:12:36+00:00Added an answer on June 7, 2026 at 12:12 am

    http://en.cppreference.com/w/cpp/language/operator_precedence
    Operators have their priority so in this case: 6 % 8 / 4 + 21 % 9 = (((6%8)/4)+(21%9))=(6/4)+(3)=4

    a[0]=6,
    a[1]=(int)7.8 = 7, (correct me if i'm wrong)
    a[2] = (int)8.0 = 8,
    a[3] = -6,
    a[4] = (int)-5.7 = -5,
    a[5] = 5,
    a[6] = (int)5.7 = 5
    

    So element with index 4 it’s -5.7 casted to integer gives -5 (the rest is just cut off)

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

Sidebar

Related Questions

sorry this is such a simple question but I can't figure it out. How
Sorry if this is a simple question, but I just can't figure out what
Sorry for the simple question, but this has been killing me and I can't
Sorry if this question may be simple, but I can't seem to find an
Sorry if this is a dead simple question but I'm confused from the documentation
Sorry, I'm sure this is simple but I'm tired and can't figure it out.
This is probably (hopefully) a pretty simple question, but I can't seem to get
Sorry if this is a simple question, but I've only recently started learn coding
Sorry for this simple question but I seem not to find any other way
This might be a dumb question but I can't get this super simple script

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.