write a program to swap two variables a=5 , b= 10 without
using third variable
Answers were Sorted based on User's Feedback
Answer / nagendra kumar
#include<stdio.h>
main(){
int a,b;
printf("Enter A value: ");
scanf("%d",&a);
printf("\nEnter B value: ");
scanf("%d",&b);
printf("\nThe value of A is:%d",a);
printf("\n The value of B is:%d",b);
a=a+b;
b=a-b;
a=a-b;
printf("\n The value of A is:%d",a);
printf("\n The value of B is:%d",b);
}
| Is This Answer Correct ? | 20 Yes | 4 No |
Answer / dhanalakshmi
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("enter the a value"));
scanf("%d",&a);//a=10
printf("enter the b value");
scanf("%d",&b);//b=5
b=b+a;
a=b-a;
b=b-a;
printf("\n The value of A is:%d",a);
printf("\n The value of B is:%d",b);
}
| Is This Answer Correct ? | 7 Yes | 2 No |
Answer / samruthi
#include<stdio.h>
void main()
{
int a=5,b=10;
printf("The value of A is:%d",a);
printf("\n The value of B is:%d",b);
b=a;
a=b;
a=b+a;
printf("\n The value of A is:%d",a);
printf("\n The value of B is:%d",b);
getch();
}
| Is This Answer Correct ? | 10 Yes | 7 No |
Answer / nagendra kumar
#include<stdio.h>
main(){
int a,b;
printf("Enter A value: ");
scanf("%d",&a);
printf("\nEnter B value: ");
scanf("%d",&b);
printf("\nThe value of A is:%d",a);
printf("\n The value of B is:%d",b);
a=(a+b)-(b=a);
printf("\n The value of A is:%d",a);
printf("\n The value of B is:%d",b);
}
| Is This Answer Correct ? | 4 Yes | 2 No |
Answer / shafi.shaik
main()
{
int a,b;
clrscr();
printf("enter a, b Value");
scanf("%d%d",&a,&b);
printf("\n%d",a);
printf("\n%d",b);
b=b-a;
a=a+b;
b=a-b;
printf("\n%d",a);
printf("\n%d",b);
getch();
}
| Is This Answer Correct ? | 1 Yes | 3 No |
c program to manipulate x=1!+2!+3!+...+n! using recursion
Whats s or c mean?
What is a pointer and how it is initialized?
a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above
what is the difference between global variable & static variable declared out side all the function in the file.
What is the benefit of using const for declaring constants?
How can I find out if there are characters available for reading?
What is a constant?
What is omp_num_threads?
What are header files and what are its uses in C programming?
What is sizeof array in c?
how to return 1000 variables from functio9n in c?plz give me code also