






































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







































int count Enough memory for 1 int
12345
float price Enough memory for 1 float
char letter Enough memory for 1 char
// This program asks the user for the number of hours worked // by 6 employees. It uses a 6-element int array to store the // values.
#include <iostream.h>
void main(void) { short hours[6];
cout << "Enter the hours worked by six employees: "; cin >> hours[0]; cin >> hours[1]; cin >> hours[2]; cin >> hours[3];
// This program asks the user for the number of hours worked // by 6 employees. It uses a 6-element short array to store the // values. #include <iostream.h>
void main(void) { short hours[6];
cout << "Enter the hours worked by six employees: "; for (int count = 0; count < 6; count++) cin >> hours[count]; cout << "The hours you entered are:"; for (count = 0; count < 6; count++) cout << " " << hours[count]; cout << endl; }
// This program asks the user for the number of hours worked // by 6 employees. It uses a 6-element short array to store the // values. #include<iostream.h>
void main(void) { short hours[6];
cout << "Enter the hours worked by six employees.\n"; for (int count = 1; count <= 6; count++) { cout << "Employee " << count << ": "; cin >> hours[count - 1]; } cout << "The hours you entered are\n";
// This program unsafely accesses an area of memory by writing // values beyond an array's boundary. // WARNING: If you compile and run this program, it could cause // the computer to crash. #include <iostream.h>
void main(void) { short values[3]; // An array of 3 short integers.
cout << "I will store 5 numbers in a 3 element array!\n"; for (int count = 0; count < 5; count++) values[count] = 100; cout << "If you see this message, it means the computer\n"; cout << "has not crashed! Here are the numbers:\n"; for (int count = 0; count < 5; count++) cout << values[count] << endl; }