Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions C/C_largest.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
#include <stdio.h>
#include<bits/stdc++.h>
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 "<<arr[2];
return 0;
}
30 changes: 12 additions & 18 deletions CPP/CPP_linear_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using namespace std;
int main()
{

int arr[10], i, num, n, c=0, pos;
int arr[10], i, num, n, f=0;
cout<<"Enter the array size : ";
cin>>n;
cout<<"Enter Array Elements : ";
Expand All @@ -13,22 +13,16 @@ int main()
}
cout<<"Enter the number to be search : ";
cin>>num;
for(i=0; i<n; i++)
{
if(arr[i]==num)
{
c=1;
pos=i+1;
break;
}
}
if(c==0)
{
cout<<"Number not found..!!";
}
else
{
cout<<num<<" found at position "<<pos;
}
for(i=0;i<n;i++)
{
if(arr[i]==num)
{
f=1;
cout<<"Element found at "<<i+1;
break;
}
}
if(f==0)
cout<<"Element not found";
return 0;
}