Concept explainers
Consider two parallel arrays of the same size, one containing strings and the second containing integers. Write C++ statements to output the information in the two arrays as a table of names and numbers. The first column of the table will contain the names left-justified in a field of 20, and the second column will contain the integers right-justified in a field of 10. Here is an example of the data when the size of the array is 2.
const int SIZE = 2;
string names[SIZE] = {"Catherine", "Bill"};
int numbers[SIZE] = {12, 2005};
Trending nowThis is a popular solution!
Chapter 13 Solutions
Starting Out With C++: Early Objects (10th Edition)
Additional Engineering Textbook Solutions
Starting Out with Python (3rd Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
Absolute Java (6th Edition)
Starting Out With Visual Basic (8th Edition)
Starting out with Visual C# (4th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
- Question 1. Read the below C program and answer the following questions. #include <stdio.h> char read_letter(); void pattern(int rows, int cols, char letter); int main(void) { int rows, cols; char letter; letter = read_letter(); printf("Enter the number of rows: "); scanf("%d",&rows); printf("Enter the number of columns: "); scanf("%d",&cols); pattern(rows, cols, letter); return 0; } char read_letter() { char letter; printf("Enter the first letter of your name: "); scanf("%c",&letter); return letter; } void pattern(int x, int y, char letter) { int i, j; printf("\n"); for (i = 0; i <x; i++) { for (j = 0; j <y; j++) { printf("%3c",letter); } printf("\n"); } return; } List all the functions that have been uses in the code and mention their type. Explain the commands that have been executed by each function. Explain the loop part and explain how to calculate the number of iterations. Run the given…arrow_forwardHi, i need help with this program in C++ Write a program that asks the user to enter the size of an array. Declare a dynamic array of type int of the size entered by the user. Initialize the array so that the elements in the first half have values equal to the square of the index, and the elements in the second half have values equal to three times the index. Print out the array with 15 values per line.arrow_forwardQuestion 3. Read the below C program and answer the following questions. #include <stdio.h> char read_letter(); void pattern(int rows, int cols, char letter); int main(void) { int rows, cols; char letter; letter = read_letter(); printf("Enter the number of rows: "); scanf("%d",&rows); printf("Enter the number of columns: "); scanf("%d",&cols); pattern(rows, cols, letter); return 0; } char read_letter() { char letter; printf("Enter the first letter of your name: "); scanf("%c",&letter); return letter; } void pattern(int x, int y, char letter) { int i, j; printf("\n"); for (i = 0; i <x; i++) { for (j = 0; j <y; j++) { printf("%3c",letter); } printf("\n"); } return; }arrow_forward
- Write a C program that uses arrays and functions to implement a calculator for twooperands. Your calculator must have five principal operations, addition ( ), subtraction ( ),division ( ), multiplication ( ), and power ( ). In the beginning of the program, show the menuof operators to the user. When the user selects one of the operators, your program gets the valuesfor operand 1 and operand 2 from the user and saves them into an array. Then pass the array to thesuitable function to calculate the result. The operating functions must return the value to the mainprogram. The calculation stops when the user press “x”. Use a global variable to save the result oflast operation. Anytime that the user types “M”, the program shows the result of last operation.hint: Each mathematic operation must be a separate function. Your main program calls those functions.arrow_forwardHelp writing a program in c++ that asks a user for a number (variable num) and then takes that number input to print out the nth term of a sequence? The sequence begins with 1 and then every number after is a prime factor of 3, 4, or 6. This needs to be done without using vectors or arrays. . . . For example: Sequence is : 1, 3, 4, 6, 8, 9, 12, 16, 18, 20, ... (cont.) User input (num) is : 6 Output : 12 (6th term) . . Please add comments explaining the code for better understanding if possible, thank you!!arrow_forwardYou are to create a C program which fills an integer array with integers and then you are to cast it as a "char * and print it out the string relating the "char * The output of the string should be your first and last name with proper capitalization, spacing and punctuation. Your program should have structure similar to: main(){ int A[100]; char *S; A[0]=XXXX;A[1]=YYYY; ... A[n]=0; -- because C strings are terminated with NULL ... printf("My name is %s\n",S); }arrow_forward
- I need complete explanation of c++ code line by line. Need Explanation of all lines of code what is happening in this code where the data is stored.? Code #include <iostream>#include <iomanip>#include <time.h>#include <fstream>#include <conio.h>#include <string.h>#include <stdlib.h>using namespace std;class Bank {public:};class ATMAccountHolders:public Bank{string accountHolders;string accountHoldersAddress, branch;int accountNumber;double startBalance;double accountBalance; double amount;int count;public:void deposit();void withdraw();void accountExit();ATMAccountHolders(){accountNumber = 7787;accountHolders = " Ammad Naseer";accountHoldersAddress = " House no.112";startBalance = 6000.00;accountBalance = 6000.00;branch = " Islamabad";amount = 20000; }}; void ATMAccountHolders::deposit(){system("cls"); cout<<" ATM ACCOUNT DEPOSIT SYSTEM ";cout<<"\n\nThe Names of the Account Holders are…arrow_forwardWrite a short computer program in C++ that will read 10 integer numbers entered from a keyboard and then print the smallest number, the largest number, and the average value. Assume all numbers are in the range [-500 … +500]. Execute the program, entering 10 values scattered across the above range, with 5 non-zero positive numbers, 4 negative numbers, and one zero. It is NOT required that that the program check for invalid entries - you may assume that appropriate values are entered correctly. Submit the source program listing and the results. Example: 30 -25 18 -3 10 0 100 -100 200 -200 Smallest = -200 Largest = 200 Average = 3arrow_forwardI need the code in C programing i am begging you please. There are several test cases. Each test case begins with a line containing a single integer n (1≤n≤1000). Each of the next n lines is either a type-1 command, or an integer 2 followed by an integer x. This means that executing the type-2 command returned the element x. The value of x is always a positive integer not larger than 100. Given a sequence of operations with return values, you’re going to guess the data structure. It is a stack (Last-In, First-Out), a queue (First-In, First-Out), a priority-queue (Always take out larger elements first), not sure(It can be more than one of the three data structures mentioned above) or impossible(It can’t be a stack, a queue or a priority queue). Sample Input Sample output 6 1 1 1 2 1 3 2 1 2 2 2 3 6 1 1 1 2 1 3 2 3 2 2 2 1 2 1 1 2 2 4 1 2 1 1 2 1 2 2 7 1 2 1 5 1 1 1 3 2 5 1 4 2 4 1 2 1 queue not sure impossible stack priority queue impossiblearrow_forward
- I was asked to repost the question to get the other parts solved: Write a program using c++ that: includes a function that reads integers consisting of students’ test scores in the range of 0-200 from a file into a one-dimensional array of size 30 includes a function to calculate the mean (add all the scores and divide by the number of scores) includes a function to calculate the median (sort the scores and then find the score in the middle—if there is an odd number of scores, the median is the middle score; otherwise, it is the average of the two middle scores) includes a function to calculate the mode (most frequently occurring score) includes a function to calculate the standard deviation includes a function to determine the number of students having scores in each of the following ranges: 0-24, 25-49, 50-74, 75-99, 100-124, 125-149, 150-174, 175-200 and output each score range followed by the number of students within that range includes a function to print everything to an output…arrow_forwardPlease fill in the blanks for C, from 1 to 68. /*The program will get the information of each client and print it right back. We could get the information of all clients first, then print them all later for better readability using an array of struct.*/ #include<stdio.h> #include<stdbool.h> #define length 70 //assume there's no names longer than 70 /*It's good practice to add all function headers to the top of the program*/ __1__ __2__ getEmployeeInfo(); __3__ printEmployeeInfo(__4__ __5__ em); __6__ __7__ getClientInfo(__8__ i); __9__ printClientInfo(__10__ __11__ cli, __12__ i); /*Employee struct: all the arrays use the same constant size defined on top name-first, last-(string) title (string) number of clients (integer) number of years working at the company(can take decimal points). */ __13__ employee { __14__ first_name[__15__]; __16__ last_name[__17__]; __18__ title[__19__]; __20__ num_clients; __21__…arrow_forwardWrite a program, USING C, to read and display the information employees in a group. Then edit the details of the employee and redisplay the entire information. Here is the list of 3 employees in a group: Employee ID Employee name Experience Salary Department 5561 Richard 1 68000 Product Development 5562 Callum 2 100000 Product Development 5563 Elon 4 150000 Product Development Your Code should generate the following output for each of the employees. Example: ********DETAILS OF Employee 1******* Employee ID = 5561 Employee Name = Richard Salary = 68000 Experience = 1 Department = Product Development Richard started learning Data Structure well and applied for a different position in the same company. He was chosen for the new role under a different department. As a result, his salary raised to 200000 and his new Department is Data Science. Modify the details of Richard and…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education