Question: A chocolate factory is packing chocolates into the packets. The chocolate packets here represent an array of N number of integer values. The task is to find the empty packets(0) of chocolate and push it to the end of the conveyor belt(array). Example 1: N=7 and arr = [4,5,0,1.9,0,5,0]. There are 3 empty packets in the given set. These 3 empty packets represented as O should be pushed towards the end of the array Input: 7- Value of N [4,5,0,1,0,0,5] - Element of arr[O] to arr[N-1],While input each element is separated by newline Output: 4519500 Example 2: Input: 6- Value of N. [6,0,1,8,0,2] - Element of arr[0] to arr[N-1], While input each element is separated by newline Output: 618200

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
25. Need C, C++, Java, Python, or Perl code for the below question. Important: Do not copy codes from prepinsta.com.
**Question:** A chocolate factory is packing chocolates into packets. The chocolate packets here represent an array of N number of integer values. The task is to find the empty packets (0) of chocolate and push them to the end of the conveyor belt (array).

**Example 1:**

N = 7 and arr = [4, 5, 0, 1, 9, 0, 5, 0].

There are 3 empty packets in the given set. These 3 empty packets represented as 0 should be pushed towards the end of the array.

**Input:**

7 – Value of N

[4, 5, 0, 1, 9, 0, 5, 0] – Elements from arr[0] to arr[N-1], with each input element separated by a newline.

**Output:**

4 5 1 9 5 0 0 0

**Example 2:**

**Input:**

6 – Value of N

[6, 0, 1, 8, 0, 2] – Elements from arr[0] to arr[N-1], with each input element separated by a newline.

**Output:**

6 1 8 2 0 0
Transcribed Image Text:**Question:** A chocolate factory is packing chocolates into packets. The chocolate packets here represent an array of N number of integer values. The task is to find the empty packets (0) of chocolate and push them to the end of the conveyor belt (array). **Example 1:** N = 7 and arr = [4, 5, 0, 1, 9, 0, 5, 0]. There are 3 empty packets in the given set. These 3 empty packets represented as 0 should be pushed towards the end of the array. **Input:** 7 – Value of N [4, 5, 0, 1, 9, 0, 5, 0] – Elements from arr[0] to arr[N-1], with each input element separated by a newline. **Output:** 4 5 1 9 5 0 0 0 **Example 2:** **Input:** 6 – Value of N [6, 0, 1, 8, 0, 2] – Elements from arr[0] to arr[N-1], with each input element separated by a newline. **Output:** 6 1 8 2 0 0
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Random variables
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
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education