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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:16:09+00:00 2026-05-26T14:16:09+00:00

I encountered this problem while solving a practice test Consider this C code to

  • 0

I encountered this problem while solving a practice test

Consider this C code to swap two integers and these five statements:

void swap (int *px, int *py) {

*px = *px – *py;

*py = *px + *py;

*px = *py – *px;

}

S1: will generate a compilation error

S2: may generate a segmentation fault at runtime depending on the arguments passed

S3: correctly implements the swap procedure for all input pointers referring to integers stored in memory locations accessible to the process

S4: implements the swap procedure correctly for some but not all valid input pointers

S5: may add or subtract integers and pointers.

Which of the above statement(s) is/are correct?

I think S2 and S3. Could anyone please confirm

  • 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-26T14:16:09+00:00Added an answer on May 26, 2026 at 2:16 pm

    I don’t believe S3 holds, since if you call it with px == py, it will just set the integer to 0 in the first line (*px = *px - *py is then equivalent to *px = *px - *px which obviously stores a 0 in *px). With all input data set to 0, it’s unable to recover and re-generate the value.

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

Sidebar

Related Questions

I encountered this problem while solving a practice test Consider the following code written
I encountered this problem while preparing for my exams. Given two arrays of numbers
I've encountered this problem (while trying to add SQL Server Database (.mdf) file to
I encountered a code design problem while working on a small application. In terms
I've encountered a problem while writing code in Delphi. Namely I can't get acces
I'm working on a practice problem set for C programming, and I've encountered this
While I was learning kohana and making single article, i encountered this problem. I
Hi i encountered this problem whereby when i initialized my String[], there seems to
Uhm I'm not sure if anyone has encountered this problem a brief description is
Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created

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.