diff --git a/C/C_largest.c b/C/C_largest.c index 9ea244c..a1c4d64 100644 --- a/C/C_largest.c +++ b/C/C_largest.c @@ -1,19 +1,11 @@ -#include +#include +using namespace std; int main() { - double n1, n2, n3; - - printf("Enter three different numbers: "); - scanf("%lf %lf %lf", &n1, &n2, &n3); - - if( n1>=n2 && n1>=n3 ) - printf("%.2f is the largest number.", n1); - - if( n2>=n1 && n2>=n3 ) - printf("%.2f is the largest number.", n2); - - if( n3>=n1 && n3>=n2 ) - printf("%.2f is the largest number.", n3); - + int arr[3]; + cout<<"Enter three different numbers: "; + cin>>arr[0]>>arr[1]>>arr[2]; + sort(arr,arr+3); + cout<<"Largest Element is "<>n; cout<<"Enter Array Elements : "; @@ -13,22 +13,16 @@ int main() } cout<<"Enter the number to be search : "; cin>>num; - for(i=0; i