Posts

Showing posts with the label largest no

Largest No. Out Of Two Nos. Without Using Relational Operator or >,<,+,- In C Language

# include <stdio.h> void main() { int a,b,c; clrscr(); printf(" \n Enter First No.:- "); scanf("%d",&a); printf(" \n Enter Second No.:- "); scanf("%d",&b); c = a/b; if(c==0)     printf(" \n %d is greater. ",b); else     printf(" \n %d is greater. ",a); getch(); }

To Find First,Second &Third Largest No. From A Given Array

# include <iostream.h> # include <conio.h> void main() { clrscr(); int f,s,t,a[50],n,i; cout<<" \n Enter Size Of Array: "; cin>>n; cout<<" \n Enter The Array:- "; for (i=0;i<n;i++) {     cin>>a[i]; } f = a[0]; s = a[0]; t = a[0]; for (i=0;i<n-1;i++) {     if (a[i] > f)      f = a[i+1];     } for(i=0;i<n-1;i++) {      if ((a[i] > s) && (f > a[i]) )         s = a[i+1]; }       for (i=0;i<n-1;i++) {      if ((a[i] > t) && (f > a[i]) && (s > a[i]))         t = a[i+1]; } cout<<" \n The First Largest No. Is " <<f; cout<<" \n The Second Largest No. Is "<<s; cout<<" \n The Third Largest No Is. "<<t; getch(); }