Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Question
Chapter 6, Problem 6E
Program Plan Intro
- Include required header files.
- Declare the function “main ()”.
- Declare required variables “var1”, “var2”, “var3”, and “i”.
- Print the values of “var1”, and “var2”.
- Loop from 0 through 13 using “for” loop.
- Add the value of “var1” and “var2” and store it in a variable “var3”.
- Assign the value of “var2” to “var1”.
- Assign the value of “var3” to “var2”.
- Print the value of “var3”.
- Return the statement.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Please submit your solution to the lab instructor once you have your program working. Your lab instructor will tell you how (s)he would like you to turn it in.
Failure to submit will result in a zero.
Write a program that asks the user to input two integers a and b. Then create an array that has all integer from a to b. Print out the array.
(Don’t forget to consider the situation of a=b, a<b, and a>b.)
Example 1:
Input two numbers: 6 2
Array is [6, 5, 4, 3, 2]
Example 2:
Input two numbers: 4 8
Array is [4, 5, 6, 7, 8]
Pass the above array as a parameter to a method called average and return the average and print it out in the main method.
(Do not use Math library to get the average.)
Please attach your screenshot below to each question a and b.
I need help with this homework question, and please explain why certain parts go where
"Write a program that displays the following pattern of prime numbers using a nested forloop. You must generate the prime numbers—you are not allowed to store the primenumbers in an array beforehand and print them from the array."
Write a program that creates a two dimensional array with 4 rows and 3 columns that contains the below numbers. Let the computer prompt you to enter these numbers.
8 6 1
7 3 0
2 5 9
5 6 7
After that, calculate and print the total and average of these values.
Chapter 6 Solutions
Programming in C
Knowledge Booster
Similar questions
- In this assignment, you will decide how to keep the inventory in the text file. Then your program must read the inventory from the file into the array. Each product must have a record in the file with the name, regular price, and type. There are several options for storing records in the file. For example, • each value takes one line in the file (i.e., three lines for one product). Then you must take care of correct handling of the ends of the lines; • all values are in one line that can be read as a string. Then you must handle the parsing of the string; • all values are in one line separated by a delimiter. Then you must handle a line with delimiters. Assume that the inventory does not have more than 100 products. But the actual number is known only after the reading of the file. Once you can read data from the file into the array, you must add a new property to the product class – a static variable that holds the number of products in the inventory. Its value must grow as reading…arrow_forwardWrite program to divide an array into two parts. Your program take an array (length is 20) and produce two new arrays. One of the arrays holds numbers divisible by 3 and the other divisible by 4. There can be some common elements belonging to two arrays.arrow_forwardWrite a program that creates an integer array of size 10 and fills the array with valuesset by the programmer (not entered by the user). Then, the program will remove all theprime numbers from the original array and store them in a new array. Note that afterthe program finishes execution, the original array should not contain any prime number.arrow_forward
- Suppose you are given a character array which is named as "JUBAIRKHAN". Array size is 10 and you have to fill up the values in following the example given below. For example, let's assume your full name is "JUBAIR KHAN" (All Capital). Now fill up the array with the ASCII values of the characters of your name without any space. Write your Full Name in all Capital Characters and fill up this "JUBAIRKHAN" array . index: 0 1 2 3 4 5 6 7 8 9 value: J U B A I R K H A N ascii : 74,85,66,65,73,82,75,72,65,78 Use the "JUBAIRKHAN" array's ASCII values to solve the following problem. Draw the following graph with the edge values. Start Vertex = 0 and all the edges value are from JUBAIRKHAN array's index. Show simulations for each step and find the single source shortest path using Dijkstra's Algorithm from the graph. Subject: C++ Programmingarrow_forwardI am trying to find a way to use an array inside my mixed color program where the user enters two prime colors to give the mixed color as the result. I do not know how to turn 'red', 'blue', and 'yellow' into and array to then ask user to enter a 0,1, or 2 for the array to use red, blue, or yellow. Can I get some help on how to use this array? #include <iostream> #include <string> using namespace std; int main(){ string arr[] = {red, blue, yellow}; string color1, color2; string mixedColor; char choice; do { cout <<"Enter first prime color '0' for red, '1' for blue, and '2' for yellow: " <<endl; cin >>color1; cout <<"Enter different second prime color, '0' for red, '1' for blue, and '2' for yellow: " <<endl; cin >>color2; if ((color1 == 0 && color2 == 1) || (color1 == 1 && color2 == 0)){ mixedColor = "purple"; }else if ((color1 == 0…arrow_forwardWrite a program that creates array of 10 integers. Ask the user to enter the data in the array. Each time the data entered in the array should be unique. Your program should not allow the user to enter the duplicate values in the array. After feeding data into the array created, create another array of the 10 integers and save the data of 1st array in the reverse order into the second array. For Example Array 1 1 2 3 4 5 6 7 8 9 10 Array 2 10 9 8 7 6 5 4 3 2 1arrow_forward
- Extend the program below so that after closing the files, program asks the user to enter a name. The program should store this input as a string, and then search the name array for the ‘search name’ just entered by the user. If the search name is found in the name array, the program will print the name, age and wage corresponding to the search name to the screen. If the search name is not found in the name array, program prints “Name not found” to the screen. The search would need to use string comparison functions. (b) #include<stdio.h>#include<stdlib.h> char c;char name[10][50];int roll[10];float marks[10]; int main (int argc, char **argv) { FILE* f; if (argc != 2) { printf("No filename in the argument"); return 1; } f = fopen(argv[1], "r"); if (f == NULL) { printf("The file cannot be opened successfully: %s\n",argv[1]); return 1; } printf("The file has been opened successfully\n\n"); int lines = 0;…arrow_forwardExtend the program belowso that after closing the files, program asks the user to enter a name. The program should store this input as a string, and then search the name array for the ‘search name’ just entered by the user. If the search name is found in the name array, the program will print the name, age and wage corresponding to the search name to the screen. If the search name is not found in the name array, your program prints “Name not found” to the screen. The search would need to use string comparison functions. #include<stdio.h>#include<stdlib.h> char c;char name[10][50];int roll[10];float marks[10]; int main (int argc, char **argv) { FILE* f; if (argc != 2) { printf("No filename in the argument"); return 1; } f = fopen(argv[1], "r"); if (f == NULL) { printf("The file cannot be opened successfully: %s\n",argv[1]); return 1; } printf("The file has been opened successfully\n\n"); int lines = 0;…arrow_forwardDo it in Python In the attached Python code, use the array built to shuffle and deal two poker hands. Change the corresponding values for all Jacks through Aces to 11, 12, 13, 14 respectively. Shuffle the deck using your written shuffle routine, then deal two hands. Comment your code and submit the Python code.arrow_forward
- Write a C# or a python program that creates an integer array of size 10 and fills the array with values set by the programmer (not entered by the user). Then, the program will remove all the prime numbers from the original array and store them in a new array. Note that after the program finishes execution, the original array should not contain any prime number.arrow_forwardHello! Please help me find the correct PYTHON CODE for this problem. ASAP! Thank you! Search and Rescue by CodeChum Admin Make a program that will accept an integer and loop for the same number of times as that of the inputted integer and input random integers and add it to the array/list one by one, per line. Afterwards, make your program accept another random integer. Using that final integer, compare from your array/list if the final integer's value is also present in your current array/list. If so, print "Present"; otherwise, print "None". Start coding now! Input The first line contains the size of the array/list. The next lines contain the integers. The last line contains an integer to be searched. 5 3 21 2 5 23 2 Output A line containing a string. Presentarrow_forwardUse the array built to shuffle and deal two poker hands. Change the corresponding values for all Jacks through Aces to 11, 12, 13, 14 respectively. Shuffle the deck, then deal two hands. Comment your code and submit the Python code. im using python 3.9.7arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education