0% found this document useful (0 votes)
32 views10 pages

Array Programs in C

The document provides 8 examples of Flowgorithm programs to perform various operations on arrays such as finding the product of array elements, printing odd numbers in an array, finding the sum of even numbers, finding the smallest element, and printing the sum of elements at odd indices. It also includes examples of searching for a number in an array and displaying the next element after a user-input number. The final example is a menu-driven bank program to read customer IDs, balances into arrays and allow searching for balances and finding the highest balance.

Uploaded by

goten10da
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)
32 views10 pages

Array Programs in C

The document provides 8 examples of Flowgorithm programs to perform various operations on arrays such as finding the product of array elements, printing odd numbers in an array, finding the sum of even numbers, finding the smallest element, and printing the sum of elements at odd indices. It also includes examples of searching for a number in an array and displaying the next element after a user-input number. The final example is a menu-driven bank program to read customer IDs, balances into arrays and allow searching for balances and finding the highest balance.

Uploaded by

goten10da
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

Array level -1

1. Design a Flowgorithm to find the product of elements of an array

Start
In function int prod_mat(int arr[], int n)
Step 1-> Declare and initialize result = 1
Step 2-> Loop for i = 0 and i < n and i++
result = result * arr[i];
Step 3-> Return result
int main()
Step 1-> Declare an array arr[]
step 2-> Declare a variable for size of array
Step 3-> Print the result
2. Design a Flowgorithm to read an array and print the odd numbers in the array.
Step 1: Start
Step 2: Declare n, i
Step 3: Input array size n from user
Step 4: Declare A[n] as integer datatype
Step 5: Assign i as zero
Step 6: Repeat
Step 6.1: Input A[i]
Step 6.2: i=i+1
Step 7: Until i==n
Step 9: for(i=0,i<n,i++)
Step 9.1: If(a[i]%2!=0)
Step 9.1.2: Display a[i]
Step 9.1.3: End IF
Step 9.2: End For
Step 10: Stop
3.Design a Flowgorithm to read an array and print the sum of even numbers in the
Array
Step 1: Start
Step 2: Declare n, i
Step 3: Input array size n from user
Step 4: Declare A[n] as integer datatype
Step 5: Assign i as zero
Step 6: Repeat
Step 6.1: Input A[i]
Step 6.2: i=i+1
Step 7: Until i==n
Step 9: for(i=0,i<n,i++)
Step 9.1: If(a[i]%2==0)
Step 9.1.2: Display a[i]
Step 9.1.3: End IF
Step 9.2: End For
Step 10: Stop
4.Design a Flowgorithm to read an array and find the smallest element in the array.
Step 1: Start
Step 2: Declare n, I,min
Step 3: Input array size n from user
Step 4: Declare A[n] as integer datatype
Step 5: Assign i as zero, min = arr[0]
Step 6: Repeat
Step 6.1: Input A[i]
Step 6.2: i=i+1
Step 7: Until i==n
Step 9: for(i=0,i<n,i++)
Step 9.1: if(arr[i]<min)
Step 9.1.2: min=arr[i]
Step 9.1.3: End IF
Step 9.2: End For
Step 10:Display the smallest element
Step 10: Stop
5.Design a Flowgorithm to read an array and print the sum of elements at odd array
indices.
Step 1: Start
Step 2: Declare n, I,sum
Step 3: Input array size n from user
Step 4: Declare A[n] as integer datatype
Step 5: Assign i as zero, sum=0
Step 6: Repeat
Step 6.1: Input A[i]
Step 6.2: i=i+1
Step 7: Until i==n
Step 9: for(i=0,i<n,i++)
Step 9.1: if(i%2!=0)
Step 9.1.2: Sum=sum+a[i]
Step 9.1.3: End IF
Step 9.2: End For
Step 10: Display the smallest element
Step 11: Stop
6. Design a Flowgorithm that searches for a number (value) in an array and display
an appropriate message. The array of numbers and the value to be searched should
be read from the user.

Step 1: Start
Step 2: Declare n, I,sum,found,toSearch
Step 3: Input array size n from user
Step 4: Declare A[n] as integer datatype
Step 5: Assign i as zero, found=0
Step 6: Repeat
Step 6.1: Input A[i]
Step 6.2: i=i+1
Step 7: Until i==n
Step 9: for(i=0,i<n,i++)
Step 9.1: Read toSearch from the user
Step 9.1.2: if(arr[i] == toSearch)
Step 9.1.3:Assign found = 1
Step 9.1.3: End IF
Step 9.2: End For
Step 10: if(found == 1)
Step 11: Display the position of the element
Step 12: Stop
7.Design a Flowgorithm that reads an array and displays the element that comes in
the array after a number entered by the user
Step 1: Start
Step 2: Declare n, I,sum,found,toSearch
Step 3: Input array size n from user
Step 4: Declare A[n] as integer datatype
Step 5: Assign i as zero, found=0
Step 6: Repeat
Step 6.1: Input A[i]
Step 6.2: i=i+1
Step 7: Until i==n
Step 9: for(i=0,i<n,i++)
Step 9.1: Read toSearch from the user
Step 9.1.2: if(arr[i] == toSearch)
Step 9.1.3:Assign next number=a[i]+1
Step 9.1.3: End IF
Step 9.2: End For
Step 10: Display the next element
Step 11: Stop
8.Write a menu driven program for a bank that read the following details of n
customers: customer id(a 4 digit number), current balance and perform the following
operations (menu driven- choice based)
a. Read a customer id number and display the balance for that customer
b. Display the id of the customer with highest balance. Also display an error
message if the search fails
Hint: Create 2 arrays: id[] and balance[]. Store the customer details in such a way
that if the id of a particular customer is stored at id[k], then his/her balance will be
stored in balance[k]

Step 1: Start
Step 2: Declare id[],balance[]I,j,
Step 3: Input array size n from user
Step 4: Declare id[n] as integer datatype
Step 5: Assign i as zero,
Step 6: Repeat
Step 6.1: Input id[n]
Step 6.2: i=i+1
Step 7: Until i==n
Step 9: for(i=0,i<n,i++)
Step 9.1: Read balance[i] from user
Step 9.1.1: Assign max = balance[0]
Step 9.1.2: : if(balance[i]>max)
Step 9.1.3:Assign max=balance[i]
Step 9.1.3: End IF
Step 9.2: End For
Step 10: Display id and balance

You might also like