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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:19:03+00:00 2026-05-12T17:19:03+00:00

bool stop = false; int f1 = 1; int f2 = 2; int f3

  • 0
bool stop = false;
           int f1 = 1;
           int f2 = 2;
           int f3 = 0;
           int sum = 2;
           while (!stop)
           {
               f3 = f1 + f2;
               sum += f3 % 2 == 0 ? f3 : 0; //THIS ONE
               stop = f3 > 4000000 ? true : false;//AND THIS ONE.
               f1 = f2;
               f2 = f3;
           }

What is that conditional operator? This is the first time I’ve seen anything like this.

  • 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-12T17:19:03+00:00Added an answer on May 12, 2026 at 5:19 pm

    The line:

    sum += f3 % 2 == 0 ? f3 : 0; //THIS ONE
    

    is the same as:

    if (f3 % 2 == 0)
      sum += f3;
    else
      sum += 0;
    

    which could of course be rewritten as

    if (f3 % 2 == 0) sum += f3;
    

    and the line

    stop = f3 > 4000000 ? true : false;//AND THIS ONE.
    

    is the same as

    if (f3 > 4000000)
       stop = true;
    else 
       stop = false;
    

    Or better yet:

    stop = f3 > 4000000; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a while loop that loops until bool done = true; In the
void GasPump::dispense() { bool cont = true; char stop; do{ cout << Press any
bool is_something_ok(int param,SomeStruct* p) { bool is_ok = false; // check if is_ok if(is_ok)
bool isValid = false; string username = someadmin; If( !String.IsNullOrEmpty(username) && !( username.IndexOf(admin) !=
bool operator()(Iterator it1, Iterator it2) const { return (*it1 < *it2); } Can someone
I created a simple window with two buttons, the first one calls a function
I've a thread that runs following tcpConnect method. I wish to stop it at
One thing that has bothered me about C# since its release was the lack
This is only the important stuff that the bluescreen shows. I'm on Windows 7
I am trying to make a stop button for this loop but it runs

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.