x

Choose Country Code

x

Direction

x

Ask a Question

  • Ask a Question
  • Scan a Question
  • Post MCQ
  • Note: File extension must be of jpg, jpeg, png, bmp format and file size must not exceed 5 MB
x

Ask a Question

x

x
x
x
Hire a Tutor

Answers and Solutions

What's Your Question?
Answer

Let two integers as x and y

int x = 10;

int y = 5;

x = x + y;

y = x - y;

x = x - y;

print the values as per the method of programming language you are using.

Answer

#include <stdio.h>

int main() {

  int x = 10, y = 5;

  x = x + y; // x now becomes 15

  y = x - y; // y becomes 10

  x = x - y; // x becomes 5

  printf("After Swapping: x = %d, y = %d", x, y);

return 0;

}

Answer

#include <stdio.h> int main() {     double firstNum, secondNum;

    printf("Enter first number: ");     scanf("%lf", &firstNum);

    printf("Enter second number: ");     scanf("%lf",&secondNum);

    // Swapping process

    firstNum = firstNum - secondNum;     secondNum = firstNum + secondNum;     firstNum = secondNum - firstNum;

    printf("\nAfter swapping, firstNumber = %.2lf\n", firstNum);     printf("After swapping, secondNumber = %.2lf", secondNum);

    return 0; }

Post Answer and Earn Credit Points

Get 5 credit points for each correct answer. The best one gets 25 in all.

Post Answer