swap prog

Answers were Sorted based on User's Feedback



swap prog..

Answer / venugopal

/* u r question is not clear but i proceed it as a swap of
two numbers*/
main()
{
int a,b,temp;
clrscr();
printf("enter two no's");
scanf("%d %d",&a,&b);
temp=a;
a=b;
b=temp;
printf("after swap no are:");
printf("%d %d" ,a,b);
getch();
} venugopal.palavalasa@gmail.com
}

Is This Answer Correct ?    5 Yes 0 No

swap prog..

Answer / tayyab

By using recent two variables swap code will be
a=3;
b=5;

a=a+b; a=8
b=a-b; b=3
a=a-b; a=5

Is This Answer Correct ?    6 Yes 1 No

swap prog..

Answer / ksrikar

a=9;
b=5;

a=a*b; // a=45
b=a/b; // b=9
a=a/b; // a=5

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More C++ Code Interview Questions

Show by induction that 2n > n2, for all n > 4.

2 Answers   Karvy, Qatar University,


Given 1 to n distinct random number of which n+1th element was duplicated. How do find the duplicate element and explain the time complexity of the algorithm.

0 Answers   Microsoft, NetApp,


write a c program, using for loop, that accepts and odds two numbers. The output must be the sum and the addens. This should be repeated 5 times while the first number is decremented by one and the second number is incremented by 1.

2 Answers   IBM, Infosys,


1. Write a program that performs the following. The user inputs a number and then enters a series of numbers from 1 to that number. Your program should determine which number (or numbers) is missing or duplicated in the series, if any. For example, if the user entered 5 as the initial number and then entered the following sequences, the results should be as shown. Input Sequence Output ---------------------- --------------- 1 2 3 4 5 Nothing bad However, if 7 were the high number, the user would see the results on the right for the following number entries: Input Sequence Output ---------------------- --------------- 1 3 2 4 5 Missing 6 Missing 7 And if 10 were the high number and the user entered the numbers shown on the left, note the list of missing and duplicate numbers: Input Sequence Output ---------------------- --------------- 1 2 4 7 4 4 5 10 8 2 6 Duplicate 2 ( 2 times) Missing 3 Duplicate 4 ( 3 times ) Missing 9

1 Answers  


Write a program using one dimensional array that searches a number and display the number of times it occurs on the list of 12 input values. Sample input/output dialogue: Enter 12 values: 13 15 20 13 30 35 40 16 18 20 18 20 Enter number to search: 20 Occurences: 3

2 Answers  






Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.

2 Answers   TCS,


1. Write a program using one dimensional array that calculates the sum and average of the five input values from the keyboard and prints the calculated sum and average.

2 Answers  


write a proram using exceptional handling create a error & display the message "THERE IS AN ERROR?... PLEASE RECTIFY"?

1 Answers  


. Write a program using two-dimensional arrays that computes the sum of data in tows and the sum of data in columns of the 3x3 (three by three) array variable n[3][3].

2 Answers   IBM,


Performance Algorithm A performs 10n2 basic operations and algorithm B performs 300 lg n basic operations. For what value of n does algorithm B start to show its better performance?

0 Answers   ASD Lab, Qatar University, UNV,


write a program using virtual function to find the transposing of a square matrix?

0 Answers  


write a program to calculate the radius for a quadratic equation use modular programming(function abitraction)hint use quadratic function

1 Answers   ICAN, Jomo Kenyatta University,


Categories