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

  • Home
  • SEARCH
  • 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 6106313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:03:58+00:00 2026-05-23T14:03:58+00:00

The original code is: if (expression1) statement1; else statement2; is it possible to transform

  • 0

The original code is:

if (expression1) statement1;
    else statement2;

is it possible to transform it into this?

expression1 ? statement1 : statement2

or it depends on the compiler? it seems that this differs within c++ standards?

Sometimes the case is if (expression1) statement1; and how can i transform that?

btw, it can be done in c.

Making the source code unreadable is exactly what i am trying to do
This is just one of the steps

error: second operand to the conditional operator is of type 'void', but the third operand is neither a throw-expression nor of type 'void'
This is what i got with g++ (TDM-2 mingw32) 4.4.1 when compile

#include <stdio.h>

void _(int __, int ___, int ____, int _____)
{
    ((___ / __) <= _____) ? _(__,___+_____,____,_____) : !(___ % __) ?     _(__,___+_____,___ % __, _____) :
    ((___ % __)==(___ / __) && !____) ? (printf("%d\n",(___ / __)),
    _(__,___+_____,____,_____)) : ((___ % __) > _____ && (___ % __) < (___ / __)) ?
    _(__,___+_____,____,_____ + !((___ / __) % (___ % __))) : (___ < __ * __) ?
    _(__,___+_____,____,_____) : 0;
}

int main() {
    _(100,0,0,1);
    return 0;
}

and if i replace the last 0 with throw 0, it will compile successfully.

  • 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-23T14:03:58+00:00Added an answer on May 23, 2026 at 2:03 pm

    expression1 ? statement1 : statement2 This is actually incorrect. The correct is this:

    expression1 ? expression2 : expression3

    Not any statement can be equivalently transformed into a single expression, so in general it is not always possible. For example:

    if(expr)
    {
       for(int i = 0; i < 2; ++i) {std::cout << i; }
    }
    else
    { 
       //something else
    }
    

    You can’t transform this into ?: expression because for is a statement, not an expression.

    Btw. It can’t be done in standard C. What you are referring to is probably the statement expression which is a GCC extension.

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

Sidebar

Related Questions

from this code will show in original color how can i change it to
This is the original code for (j = 0; j <= 30; j++) {
I'm making a code that is similar to this: #include <stdio.h> double some_function( double
I have this piece of LINQ code private static void Original() { using (var
The original code: public List<Contact> GetContactListEntityCompiledLINQ() { if (entities == null) entities = new
here is the original code: public static int getInt () { Scanner in =
I've got a webapp whose original code base was developed with a hand crafted
I have a plugin where the original code is ... // when the DOM
The code below is (hopefully) a minimized testcase of my original problem. I'm trying
My PHP code below shows an image on browser as its original size 300x300.

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.