+ 2
can anyone tell me the right code please
// the code is here// //this is a program to swap the value os two varibles #include <stdio.h> #include <stdlib.h> int main() { int D,con_of_D,con_of_C; printf("PLease enter a numerical value for D?\n"); scanf("%d",&con_of_D); D=con_of_D; printf("PLease enter a numerical value for C?\n"); scanf("%d",&con_of_C); printf("The value for D is %d\n",&con_of_D ) ; printf("The value for C is %d\n",&con_of_C ); con_of_D=con_of_C; con_of_C=D; printf("Now The value for D is %d\n",&con_of_D ) ; printf("Now The value for C is %d\n",&con_of_C ); return 0; }
11 Answers
+ 4
@BlazingMagpie He has already taken a temporary variable "D"
+ 3
The code is almost correct.
You just need to remove "&" from last 4 printf(s) and it will be working fine :)
+ 3
"&" is "address of"
It is not used when printing values in printf();
+ 1
You need a temporary variable.
Set temp. var to var A
Set var A to var B
Set var B to temp. var
+ 1
Oh, didn't see it in a wall of code.
+ 1
Swap them without using third variable đ
https://code.sololearn.com/c23d4OiJdole/?ref=app
+ 1
cool man
+ 1
thanks
+ 1
hey man i need some suggestions
+ 1
is visual basic better to learn than c
+ 1
As someone who had to learn and make script in VBA, I recommend C