0% found this document useful (0 votes)
5 views7 pages

Problem Solving and Programming

The document outlines a menu-driven program for array operations, including reading, printing, summing elements, finding the minimum number, and searching for an element. It provides a detailed algorithm for implementing these functionalities and describes user interactions for selecting options. The program continues to loop until the user chooses to exit, ensuring a user-friendly experience.

Uploaded by

krishnaramanj618
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views7 pages

Problem Solving and Programming

The document outlines a menu-driven program for array operations, including reading, printing, summing elements, finding the minimum number, and searching for an element. It provides a detailed algorithm for implementing these functionalities and describes user interactions for selecting options. The program continues to loop until the user chooses to exit, ensuring a user-friendly experience.

Uploaded by

krishnaramanj618
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

PROBLEM SOLVING AND

PROGRAMMING
Name:- Krishna Ramanbainwad
ET-E BATCH-2 ROLL NO. 36 PRN:12410651

Assignment-4: Menu Driven Program of arrays


Write a Menu Driven Program to perform the
following
operations on the array:
a. Read Array
b. Print Array
c. Print Addition of Array Elements
d. Find Minimum Number from Array
e. Search an Element from given array. If possible
print the location of the element.
Soln :
Algorithm:
• Start: The program begins.
• Get Array Size:
• Ask the user how many numbers they want to
put in
the list (array).
• Remember this number (let's call it n).
• Get Array Elements:• Ask the user to enter n
numbers.
• Store these n numbers in the list (array).
• Show Menu and Get Choice:
• Keep doing the following steps until the user
chooses
to exit:
• Show a list of options to the user:
• Print all the numbers in the list.
• Add up all the numbers in the list and show the
total.
• Find the smallest number in the list and show it.
• Ask the user for a number to look for in the list,
and
then search for it.
• Exit the program.
• Ask the user to choose one of the options by
typing its
number.
• Remember the user's choice.
• Perform Action based on Choice:
• If the choice is 1 (Print Array):
• Go through each number in the list from
beginning to
end.
• Show each number.
• If the choice is 2 (Add Elements):
• Start with a total of 0.
• Go through each number in the list.
• Add the current number to the total.
• Show the final total.
• If the choice is 3 (Find Minimum):• Assume
the first number in the list is the smallest so
far.
• Go through the rest of the numbers in the list.
• If you find a number that is smaller than the
smallest
number found so far, update the smallest number.
• Show the smallest number found.
• If the choice is 4 (Search Element):
• Ask the user for the number they want to find.
• Look through the list from beginning to end.
• If you find the number:
• Tell the user that the number was found and
where it
was found (its position).
• Stop searching.
• If you go through the whole list and don't find the
number:
• Tell the user that the number was not found.
• If the choice is 5 (Exit):
• Show a message saying the program is ending.
• Stop the loop and finish the program.
• If the choice is anything else:
• Show a message saying the choice is not valid.
• Repeat: Go back to step 4 to show the menu
again
(unless the choice was 5).
• End: The program finishes completely.

Flowchart:-
Input:-
Output:-

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy