write a program to swap two numbers without using temporary
variable?
Answers were Sorted based on User's Feedback
Answer / it diploma student
let a and b be the variables
a=a+b
b=a-b
a=a-b
if we take a=5 and b = 7 then
a = 5+7 = 12
b = 12-7 = 5
a = 12-5 = 7
hence swaped...
Is This Answer Correct ? | 26 Yes | 3 No |
Answer / guest
[code]
main()
{
int a=10;
int b=20;
printf("a = %d\nb = %d\n",a,b);
a =a+b; b=a-b; a=a-b; // This is first way.
a =a*b; b=a/b; a=a/b;
printf("a = %d\nb = %d\n",a,b);
}
[/code]
[code]
main()
{
int a=10;
int b=20;
printf("a = %d\nb = %d\n",a,b);
a =a*b; b=a/b; a=a/b; //This is second way
printf("a = %d\nb = %d\n",a,b);
}
[/code]
Is This Answer Correct ? | 19 Yes | 2 No |
Answer / sam
let a and b be variables
a^=b^=a^=b;
by performing this logic from right hand side we can swap
two variables
Is This Answer Correct ? | 6 Yes | 5 No |
#include<stdio.h> #include<conio.h> void main() { clrscr(); int a=0,b=0,c=0; printf("enter value of a,b"); scanf(" %d %d",a,b); c=a+b; printf("sum is %d",c); getch(); }
prototype of sine function.
Write a program to identify if a given binary tree is balanced or not.
program to convert a integer to string in c language'
write a program to display the numbers in the following format 4 4 3 3 3 3 2 2 2 2 2 2 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 2 2 2 2 2 3 3 3 4
Explain what is a program flowchart and explain how does it help in writing a program?
How can I sort a linked list?
What are high level languages like C and FORTRAN also known as?
Taking an example,differentiate b/w loader and linker ?
#include<stdio.h> int SumElement(int *,int); void main(void) { int x[10]; int i=10; for(;i;) { i--; *(x+i)=i; } printf("%d",SumElement(x,10)); } int SumElement(int array[],int size) { int i=0; float sum=0; for(;i<size;i++) sum+=array[i]; return sum; } output?
What are near, far and huge pointers?
0 Answers Hexaware, Thomson Reuters, Virtusa,
What should not contain a header file?