4 like 1 dislike
3.7k views

Write a program to swap the values of two variables. The program will ask the user to input variables x and y with numerical values. You must write code that exchanges their values: the value of x after your code runs must equal the value that y had before your code ran, and the value of y after your code runs must equal the value that x had before your code ran.

寫一個交換兩個變數的程式

Example input:

3
5

Example output:

5
3

Remember: Your output may be 100% correct, but your code matters!

[Exercise] Coding (C) - asked in Chapter 2: C Fundamentals by (12.1k points)
ID: 25484 - Available when: Unlimited - Due to: Unlimited

edited by | 3.7k views
0 0
u

61 Answers

0 like 0 dislike
Hidden content!
* ** ** ** * * *

int main()

{
*** * ** ** ** * * ** *** ** i,j,k;
**** * * ******** ** *   *** * * * \n ****** ** **** * ***
* *** ***** ** ** * *** * ** * * * *** * **

}
answered by (-32 points)
edited by
0 0
prog.c:3:1: warning: return type defaults to 'int' [-Wimplicit-int]
 main()//\xe4\xbd\x8d\xe7\xbd\xae\xe4\xba\x92\xe6\x8f\x9b*
 ^~~~
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
* *** * *** * * * * * x,y,tem=0;
* * * * ** * * ** * * * ** * * * ** * *** ** * *
* * ** * * * ** * * * **
* ** *** * * ****** *
** *** **** * * ** *****
* ** * * * ** * * * * * * ****** ** *
}
answered by (-214 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main()
{
* ** * * **** *** x,y,temp;

*** *** ** *** * *** * *** * *** *
*** *** * * * ** ** *** * * **** * * **

** * * *** ** ** *
* ** ** * ** * **** * * ** *
*** ***** *** * * *

****** * **** ** ** * * * * ** *
* * ** * * *** * ** * * * * ****

* *** ** * ** ** * 0;
}
answered by (-16 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include ***** * * * *

int main()

{
*** ***** * * ** **** *** x,y;
*** * * * *** * ** **** * * ** ***** **
**** * * **** * * * *** ** ** **** *** * *

*** * * *** *** 0;

}
answered by (-249 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include * ********

int main()
{
* *** ** * **** ** **** * x, y ,temp;

** ** * * *** * * ***** *** * * ***** &x);
** * **** * * **** * ***** ** * &y);

** * * *** *** * *
* * * *** ** * ***** ** * *
*** ** * * * ******

* ** ** *** ** ** *** * **** * ** **** * * x);
*** **** * * *** * ***** *** * y);
******* ** ** * * **** ***** ** 0;
}
answered by (-168 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>

int main()
{
** ** ********* ** ****** * x;
** ** **** ** *** *** ** y;
** * ****** ** temp;

* ** * *** * * **** ** * ****** ** * * ** ** * &y);

* *** * * * **** *** ** * ** = x;
*** **** * * ** * * ** * = y;
** * * * ** * * * * **** = temp;

** * ** ** * * ** ***** * *
* **** * *** * *** * * ** * * *** *

* * * * *** * * ***** * 0;
}
answered by (-193 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
* ********* *** ** * *** first,second,temp;
*** ** * * * * * * *** * **** * *** * * ** * *** * * *
* * * * * * *** ** =second;
** * * ** ** * *** ** *** ** =first;
* * ***** ** ** *** * = temp;
* ** * * ** *
*** * *** *** * **** ** * ** * *** * first);
*** **** ******* **** ** * * *** *** second);

***** ** ** *** * *** *
* ***** * * * * * ***** * 0;
}
answered by (323 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include * ** **

int main()

{
* * ** ***** * * x, y, temp;




* ** ******* *** * ** **** * * * * &x, &y);
** ***** *** * * *** * * = * ****** * **** *


** ** *** * * ** *** * * * *** = x;
** * * *** ** **** * * * *** ** *** y;
*** ** ** ** **** *** ** * ** * temp;
** * *** * ** *** * * ** ** = %d\ny = * * x, y);






** * ***** **** ** * 0;
answered by (-167 points)
0 like 0 dislike
Hidden content!
#include **** * **



int main (void)



{
* * ********* * *** * a,b,c,d;
* * *** * * ** *** ** * * ** * *** ** ** ** *** **** *
* *** ** * * ** * *** * * ** **** *** * *


*** *** * ** ** * * * ** 0;

}
answered by (-204 points)
0 like 0 dislike
Hidden content!
#include * * ** ** * * *** ***

int main (void)

 {
** * x,y,z;


** ** ** ***** * * * ** * ***
* * * * **** * * * *** * *
**** ****
*
*** ***
*** * * *** ***** *******


** *** 0;
*
answered by (-254 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.100.202
©2016-2024

Related questions

2 like 0 dislike
50 answers
[Exercise] Coding (C) - asked Sep 28, 2017 in Chapter 2: C Fundamentals by thopd (12.1k points)
ID: 25483 - Available when: Unlimited - Due to: Unlimited
| 3.3k views
1 like 0 dislike
73 answers
[Exercise] Coding (C) - asked Sep 28, 2017 in Chapter 2: C Fundamentals by admin (9.9k points)
ID: 25482 - Available when: Unlimited - Due to: Unlimited
| 4.3k views
3 like 0 dislike
116 answers
[Exercise] Coding (C) - asked Oct 5, 2017 in Chapter 3: Formatted Input/Output by thopd (12.1k points)
ID: 25729 - Available when: Unlimited - Due to: Unlimited
| 8.3k views
12,783 questions
183,443 answers
172,219 comments
4,824 users