Alright, so I'm reading a book on C programming and this is an assignment after the first chapter.
"Two numbers are input through the keyboard into two locations C and D. Write a program to interchange the contents of C and "
I've managed to do it but to me it seems like I've done it too complicated. There should be an easier solution to doing this :P
My solution:
Code:
main()
{
int C, D, C1, D1;
printf("Enter a value into location C: ");
scanf("%d", &C);
printf("Enter a value into location D: ");
scanf("%d", &D);
printf("%d %d", C, D );
printf("\n");
C1 = C + 1;
D1 = D + 1;
C = D1 - 1;
D = C1 - 1;
printf("%d %d", C, D);
}