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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:45:25+00:00 2026-06-17T13:45:25+00:00

Can I assign an operator symbol to a variable and use that variable for

  • 0

Can I assign an operator symbol to a variable and use that variable for a conditional check?

char operator= '>';
int val1=10;
int val2=24;
if(val2 operator val1){

    /* some code*/

}

Why cant I use the operator variable inside conditions?

  • 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-17T13:45:26+00:00Added an answer on June 17, 2026 at 1:45 pm

    Code written in any programming language needs to be converted to Assembly Language. When this happens, every code statement written in High Level language gets translated to instruction / set of instructions in Middle Level equivalent i.e.
    JAVA code will get translated to Machine Specific instructions in Assembly Language.

    Here addition operation in following statement,

    int a = a + 10;
    

    May get converted to

    ADD A 1010;

    And when we try to access a variables value, it may get converted to READ instruction.

    So, when you try to use ‘>’ in a variable,

    char operator= '>';
    int val1=10;
    int val2=24;
    if(val2 operator val1){
    
    /* some code*/
    
    }
    

    The if statement,

    if(val2 operator val1) 
    

    will convert to an invalid instruction.
    Instead of generating an equivalent for comparison of two values, it will READ ‘operator’ variable.

    This will obviously, lead to wrong interpretation.

    Hence, doing such thing is not allowed.

    Every compiler(java , gcc etc ) may behave differently but the target is same. If you read Complier / Compilation / Execution more, you will know more.
    These are some links:

    http://www.coderanch.com/t/559258/java/java/java-codes-converted-assembly-JVM

    Do programming language compilers first translate to assembly or directly to machine code?

    Steps for Compilation of A C program.

    http://www.herongyang.com/Computer-History/C-Program-Compilation-and-Execution-Process.html

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

Sidebar

Related Questions

I want to overload the operator , so that I can assign my fraction
Using C++ with boost. In Boost.Assign can I use the new operator with map_list_of?
Im trying to overload the [] operator in c++ so that I can assign
My question is if we can assign/bind some value to a certain item and
can we assign null value to struct type of variable? struct MyStruct { }
How can I use the += operator for a string in PHP? Below is
In SQL I can use the IN operator: select * from project where id
I'm converting some Scheme code to Clojure. The original uses a dispatching pattern that's
Is there some shorthand in Javascript to assign a variable if it evaluates to
Perl has a conditional operator that is the same a C's conditional operator .

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.