IHYPRESS.NET
C
HOME | ASP | C | CSS | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
Earn Free Bitcoin
COne Dimensional Arrays ❯ Parallel Arrays
<07.11>
#include <stdio.h> #define SIZE 6 int main (void) { // three parallel arrays int codebar [6] = {262844, 717813, 980209, 762900, 462090, 320703}; double price[6] = {19.99, 23.75, 49.95, 60.00, 17.99, 99.95}; char size[6] = {'S','L','M','S','L','L'}; int code; int i; int product = -1; printf ("Enter product code: "); scanf ("%d", &code); for (i=0; i < SIZE; ++i) if (code == codebar[i]) product = i; if (product == -1) printf ("Product not found.\n"); else { printf ("Product code: %d.\n", codebar[product]); printf ("Size: %c.\n", size[product]); printf ("Price: $%0.2lf.\n", price[product]); } return (0); }
Hergestellt in Deutschland / Made in Germany
Enter product code: 980209 Product code: 980209. Size: M. Price: $49.95.
COPYRIGHT © 2015-2024 IHYPRESS.NET. A DIVISION OF IHY PRESS. ALL RIGHTS RESERVED.