write a program to swap Two numbers without using temp variable.

Answer Posted / sneha chorghade

#include<stdio.h>
void main()
{
int a=2,b=3;
printf("before swap the value is:::");
printf("a=%d\tb=%d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("after swap the value is:::");
printf("a=%d\tb=%d",a,b);
}

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is const keyword in c?

734


What functions are used in dynamic memory allocation in c?

584


Write a C program that will accept a hexadecimal number as input and then display a menu that will permit any of the following operations to be carried out: Display the hexadecimal equivalent of the one's complement. (b) Carry out a masking operation and then display the hexadecimal equivalent of the result. (c) Carry out a bit shifting operation and then display the hexadecimal equivalent of the result. (d) Exit. If the masking operation is selected, prompt the user lor the type of operation (bitwise and, bitwise exclusive or, or bitwise or) and then a (hexadecimal) value for the mask. If the bit shifting operation is selected. prompt the user for the type of shift (left or right), and then the number of bits. Test the program with several different (hexadecimal) input values of your own choice.

4828


Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1

3641


Explain data types & how many data types supported by c?

572






while initialization of array why we use a[][2] why not a[2][]...?

1857


What is function definition in c?

576


What is static function in c?

621


What are disadvantages of C language.

638


Why C language is a procedural language?

612


Explain the advantages and disadvantages of macros.

612


An integer that indentifies the position of a data item in a sequence of data items a) value b) number c) index d) all of the above

641


Can we replace the struct function in tree syntax with a union?

768


What is #include in c?

590


write an algorithm to display a square matrix.

2213