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
Continue with Google
or use


Have an account? Sign In Now

Sign In

Continue with Google
or use

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

Sorry, you do not have permission to ask a question, You must login to ask a question.

Continue with Google
or use

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.

Network Classmate Logo Network Classmate Logo
Sign InSign Up

Network Classmate

Network Classmate Navigation

  • Home
  • Article
  • Q&A
  • Guest Post
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Feed
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
Home/ Questions/Q 3791
Next
In Process
Vipin Chauhan
Vipin ChauhanLevel 30
Asked: October 24, 20212021-10-24T18:23:23+05:30 2021-10-24T18:23:23+05:30

What Is The Value Of Ans After The Following Code Has Been Executed?

What Is The Value Of Ans After The Following Code Has Been Executed?
  • 0
  • 1 1 Answer
  • 20 Views
  • 0 Followers
Answer
Share
  • Facebook

    Related Questions

    • What Do You Mean By Https?
    • How To Check TLS Version On Aix Server?
    • How To Change Permissions For Entire Directory In Linux?
    • What Does The Tracert Command Do?
    • How To Connect Uverse Receiver To Wifi?

    1 Answer

    • Voted
    • Oldest
    • Recent
    1. Maryam Khalid Bronze
      2022-01-19T00:43:01+05:30Added an answer on January 19, 2022 at 12:43 am

      What will be the value of ans after the following code has been executed?

      int ans = 10;

       int x = 65;

       int y = 55;

       if (x >= y)

       ans = x + y;

       A) 10

       B) 120

       C) 100

       D) No value, there is a syntax error.

       None

      Answer: Option B 120

      Explanation: The code consists of three variables ans, x, and y, and the values held by them are 10,65, and 55 respectively. If the variable x has a greater value than variable y, then if statement will run ans=x + y. The running of the statement will sum x with y ->65+55 and the already given value of ans is overwritten by the sum of the result which is 120.

      Conditional statement

      The purpose of the conditional statement is to decide based on the given conditions. in case of no condition, the conditional statement will automatically execute, And if some of the condition is present then the flow of execution is changed and the result is according to it and the whole process is known as the decision making. conditional statements have different forms such as:

      • If statement.
      • Else-if statement.
      • Switch statement.

      If statement

      The first condition of the operating system is the If statement. the syntax is easy it starts with IF followed by the braces and the condition which needs to be met is a place between the braces. the If condition works by checking whether the condition in the expression is true or false. If the answer is true then the statement runs otherwise it skips to another block.

      Syntax : if(condition) {}

      Example : if (today==Monday)

      {

      Cout<< “good morning”;

      }

      Else If statement

      Moreover, if condition checks only one condition but else if check multiple conditions .the else if have an almost same pattern such as if start and close with brace along with the condition, and the condition is not true then else if and the next result will display to the screen

      Syntax: if(condition)

      {}

      Else if(condition){

      }

      Example: if (today== “rainy”)

      {

      Cout<<” read at the home”;

      }

      Else if (today== “sunny”)

      {

      Cout<<” read in the library”;

      }

      Then else if check the condition from the start if the first condition is true then other ones will terminate and if it is false then the code moves to the second condition and continuously runs until the condition is true.

      Switch statement

      The switch statement makes the code more understandable rather than if, else if statements. The block is terminated by the break keyword in the switch statements. the statements in the switch are shown with the cases.

      Syntax: switch {condition)

      {

       case 1:

      break;

      case 2:

      break;

      default:

      break;

      }

      Example:

       Int today=2;

      Switch(today)

      {

      Case 1:

      Cout<<” read in the library”;

      Break;

       Case 2:

      Cout<<” read at home”;

      Break;

      Default:

      Cout<<” get some sleep”;

      }

      The switch statement runs till the true value is returned and the code is terminated with the break keyword. And in case of false the default statement will run.

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

    You must login to add an answer.

    Continue with Google
    or use

    Forgot Password?

    Need An Account, Sign Up Here

    Sidebar

    Top Members

    Shailendra Yadav

    Shailendra Yadav

    • 2k Questions
    • 52k Points
    Level 50
    Sneha Singh

    Sneha Singh

    • 2k Questions
    • 41k Points
    Level 40
    Nilay Sharma

    Nilay Sharma

    • 0 Questions
    • 33k Points
    Level 30
    • Popular
    • Comments
    • Farwa Khalid

      Half Duplex Versus Full Duplex

      • 3 Comments
    • Farwa Khalid

      What Is Split Horizon

      • 0 Comments
    • Farwa Khalid

      What Is Ping Spoofing

      • 0 Comments
    • Farwa Khalid

      What Is Wireless Isolation?

      • 0 Comments
    • Farwa Khalid

      What Is Radio Network Controller?

      • 0 Comments
    • What is Circuit Switching - Network Classmate
      What is Circuit Switching - Network Classmate added a comment […] needs to be established. It is additive into two… November 30, 2022 at 11:36 am
    • Difference Between Router And Switch - Network Classmate
      Difference Between Router And Switch - Network Classmate added a comment […] router works in the full-duplex transmission mode. However, we… November 30, 2022 at 11:36 am
    • Communication Protocols - Network Classmate
      Communication Protocols - Network Classmate added a comment […] receiver. It is two wired protocols. Rx and Tx… November 30, 2022 at 11:35 am

    • Home
    • Groups page
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges




    Footer

    Important Links

    • Home
    • Article
    • Q&A
    • Guest Post

    Useful Categories

    • Basic Networking
    • Basic Security
    • CCNA R & S
    • CCNA Security
    • Download

    Legal Stuff

    • About Us
    • Contact Us
    • Privacy Policy
    • Terms of Service
    • User Data Policy

    Social Links

    • Facebook
    • Instagram
    • Twitter
    • Telegram
    • Linkedin

    Copyrights © 2023 Network Classmate™. All Rights Reserved.
    Designed by LeadsNut

    Manage Cookie Consent
    To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
    Functional Always active
    The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
    Preferences
    The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
    Statistics
    The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
    Marketing
    The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
    Manage options Manage services Manage vendors Read more about these purposes
    View preferences
    {title} {title} {title}