Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 6, Problem 2E
Program Plan Intro
- Include required header files.
- Declare the function “main ()”.
- Declare an array named “values []” with size 10.
- Declare a variable named “index”.
- Loop from “0” through the size of the array using “for” loop.
- Set the array index to 0.
- Loop from “0” through the size of the array using “for” loop.
- Display the array values using “printf ()” statement.
- Return the statement.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
a. Declare an array A of 50 elements of type intb. Output the value of the first element of array Ac. Set the 25th element of the array A to 26d. Set the value of the 10th element of array A to 3 times the value of the 40th element of array A plus 10 e. Use for loop to output the value of an element array A if its index/ subscript is a multiple of 2 and 3
a. Declare an array A of 50 elements of type int
b. Output the value of the first element of the array A
c. Set the 25th element of the array A to 26
d. Set the value of the 10th element of the array A to 3 times the value of the 40th
element of array plus 10
le. Use for loop to output the value of an element of array A if its index / subscript is a
multiple of 2 or 3
Write a program that takes 20 elements of array from user at run time. Find maximum element of array and swap it with last element of array. Display before and after swapping array in C++
Chapter 6 Solutions
Programming in C
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Please help me find the C CODE for this problem. Thank you! 3. 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_forwardIn a C++ program, you need to store the ID's and GPS's for 25 students. 1. Define 2 arrays that may be used in parallel to store the ID's and GPS's. 2. Write a loop to print the ID and GPA arrays in columns, with column headings. Put the information for each student on its own line.arrow_forwardC++ create an array (call it arr) of size 5 In a for loop , use scanf to read 5 numbers into your array then use another for loop to add the 5 numbers in the array together and print the result.arrow_forward
- Modify the Program to get the same output display for all elements in the numbers array by using pointers.arrow_forwardLanguage: C Print a Mayo pyramid with # characters depending on user input, i.e., the pyramid height h. To this end, update the size of the array for each level of the pyramid (for each for loop passing) using the realloc function. First of all, allocate an array for the first row. You need the allocate the memory for h + 2 characters for the first row. Fill it with spaces, using the memset(row, ’ ’, h+2) command. For each row i, expand the array size to h + 4 + i, replace the last two characters of the line with # sign, followed by the string’s null terminator. That’s why you need increase the size by 2, with the respect to the original allocation, and then by 1 at each step. You also need to replace the space at the position h − 1 − i with the # character (the left slope of the pyramid). Print and examine your results, free the memory and use the valgrind function to check memory usage.arrow_forwardWrite a C PROGRAM that creates an array of 10 integers. The array should be populated with values: each element should be equal to its subscript/index. The program should then print each element. Make use of a loop in storing values to the array. Make use of another loop in printing the values of the array.arrow_forward
- 2. 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. Present -USED JAVA PROGRAMMING LANGUAGEarrow_forwardCREATE A PROGRAM WITHOUT USING ARRAYarrow_forwardUse a loop with indirect or indexed addressing to reverse the elements of an integer array in place.Do not copy the elements to any other array. Use the SIZEOF, TYPE, and LENGTHOFoperators to make the program as flexible as possible if the array size and type should be changedin the future.arrow_forward
- Write a c++/cpp program which declares an array of n cylinders (use n=5). Initialize the array values by writing a loop which asks the user to input the radius and the height of each array element.arrow_forwardIt is a written project, you just need to submit a text file in txt, or docx or pfd format and don't have to submit your testing codes. For the following array x [10] = { 45, 20, 50, 30, 80, 10, 60, 70, 40, 90}show the contents of x after the function call split Pos = split(x, 0, 9) is executed, and give the value of the array index splitPos (the first is the pivot). Modify quicksort() to incorporate this modification: In quicksort, we do not splitting sublists further when they have fewer than LOWER_BOUND elements for some constant LOWER_BOUND. When execution of the quicksort algorithm terminates, simply sort the whole list using insertion sort. Include the modified code in this document Use the similar diagram as for merge-sorting the following list of numbers : 8, 2, 9, 4, 5, 3, 1, 6 Upload your solutions in a document file.arrow_forwardConsider the following code fragment.Trace the code and for each iteration of the while loop write the updated values of x and y. What does this code finally print out on lines 10 and 11?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning