-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswap.c
79 lines (54 loc) · 1.43 KB
/
swap.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <stdio.h>
void swap(int *x, int *y) //defining function called swap which swaps using pointers showing that you can
// access data outside of the scope of the current run time scope.
{
int z = *x;
*x = *y;
*y = z;
}
int main()
{
int a = 45, b = 35;
printf("Before Swap\n");
printf("a = %d b = %d\n",a,b);
swap(&a, &b);
printf("After Swap with pass by reference\n");
printf("a = %d b = %d\n",a,b);
return 0;
}
// #include <stdio.h> //standard input output built into c library
// typedef int number;
// int main() {
// number c;
// printf( "Enter a value :");
// fflush(stdout); //ECLIPSE BUG
// c = getchar( );
// printf( "\nYou entered: ");
// putchar( c );
// return 0;
// }
//STRING
//READ/WRITE using get and put
// #include <stdio.h>
// int main( ) {
// char str[100]; //char array STRING used as buffer
// printf( "Enter a value :");
// fflush(stdout); //ECLIPSE BUG
// gets( str );
// printf( "\nYou entered: ");
// puts( str );
// return 0;
// }
//You define type of I/O
//scanf and printf
//reading two items a string and int
// #include <stdio.h>
// int main( ) {
// char str[100];
// int i;
// printf( "Enter a value :");
// fflush(stdout); //ECLIPSE BUG
// scanf("%s %d", str, &i);
// printf( "\nYou entered: %s %d ", str, i);
// return 0;
// }