write a program to swap two variables a=5 , b= 10 without
using third variable

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is const volatile variable in c?

771


An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode

834


List the different types of c tokens?

820


Can you assign a different address to an array tag?

895


which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above

1383


What does the message "automatic aggregate intialization is an ansi feature" mean?

914


What is the difference between strcpy() and memcpy() function in c programming?

844


What is a double c?

758


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

2291


What are the types of i/o functions?

956


What is typedef?

975


What are the different types of data structures in c?

841


What is the purpose of realloc()?

872


Write a program to print fibonacci series without using recursion?

823


How can you tell whether a program was compiled using c versus c++?

830