/* Program for finding SMALLEST number from 'n' entered numbers */ #include <iostream> using namespace std; int main() { int count, small, num; cout << "How many numbers do u want to enter?\t"; cin >> count; cout << "Enter number?\t"; cin >> num; small = num; while (count>1) { cout << "Enter number?\t"; cin >> num; if (num < small) small = num; count--; } cout << "/nSMALLEST number is \t" << small << endl; return 0; } /* Program for finding LARGEST number from 'n' entered numbers. */ #include <iostream> using namespace std; int main() { int count, large, num; cout << "How many numbers do u want to enter?\t"; cin >> count; cout << "Enter number?\t"; cin >> num; large = num; while (count>1) { cout << "Enter number?\t"; cin >> num; if (num > large) large = num; count--; } cout << "LARGEST number is \t" << large << endl; return 0; } /* Program for finding LARGEST and SMALLEST number from 'n' entered numbers. */ #include <iostream> using namespace std; int main() { int count, large, small, num; cout << "How many numbers do u want to enter?\t"; cin >> count; cout << "Enter number?\t"; cin >> num; large = num; small = num; while (count > 1) { cout << "Enter number?\t"; cin >> num; if (num > large) large = num; if (num < small) small = num; count--; } cout << "\nLARGEST number is \t" << large << endl; cout << "SMALLEST number is \t" << small << endl; return 0; }
This blog is about coding in some commonly used "High Level Languages" like C, C++, Java etc. At first, I will post here basic programs written in C++ language only.
Thursday, November 27, 2014
Programs for finding SMALLEST or LARGEST number from 'n' Entered Numbers
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment