0

can you help me what is this code means?

#include <iostream.h> int main() { int a,k,b,c; cout<<"enter 3 numbers : "; cin>>a>>b>>c; if ( b>a) { k=a; a=b; b=k; } if ( c>a) { k=a; a=c; c=k; } if ( c>b) { k=b; b=c; c=k; } cout<<"max number is : "<<a<<endl; cout<<"mid number is : "<<b<<endl; cout<<"min number is : "<<c<<endl; return 0; }

24th Jun 2018, 8:09 PM
sajjad saghi
sajjad saghi - avatar
2 odpowiedzi
+ 4
https://code.sololearn.com/cCnSO2662285/?ref=app your given has some errors i have corrected them in this new code. so let me explain how this code works first we have taken 3 nos from user a,b and c. then we have an if statement in which if b is greater than a then the variable k takes the value of a and a takes the value of b and b takes the value of k next if c is greater than a then k takes the value of a, a of c and c of k similarly the third if statement works finally we print the values of a,b and c
24th Jun 2018, 8:42 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
0
The values are swapped
25th Jun 2018, 5:23 AM
Aveek Bhattacharyya
Aveek Bhattacharyya - avatar