Server IP : 172.16.15.8 / Your IP : 3.145.8.2 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/lmking1/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// File name: input3.cpp // Class: CS 212 Comp. Prog. II // Author: L'Tia King // Instructor: Dr. Wang // Date: 28 January 2009 // Compile: g++ input.cpp // Run: ./a.out // // Goal: The program reads a pos. number and outputs it, smalllest, sum, // len, and quits when reading a 0 or a neg. #include <iostream> using namespace std; int main() { // 1. decl float x[20]; float smallest, sum=0, len=0; // 2. read cout << "Input a pos., or quit for 0 and neg.: "; cin >> x[len]; smallest = x[len]; // 3. process and out while(x[len] > 0) { // process cout << "The number is: " << x[len]; sum += x[len]; if(smallest > x[len]) smallest = x[len]; cout << "\n\nInput a pos., or quit for 0/neg.: "; len ++; cin >> x[len]; } cout << "Sum is: " << sum << ". Length is: " << len << "\n"; cout << "The smallest is: " << smallest << "\n"; cout << "\n\nDone. Bye-Bye.\n\n"; return 0; }