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

Algo N Flow Chart of All EC Programs

The document outlines algorithms and flow charts for eight different programs, including arithmetic and logical operations, data transfer, summation of digits, factorial calculation, square lookup, finding largest/smallest numbers in an array, sorting numbers, and counting bits in memory. Each program includes a step-by-step algorithm and a corresponding flow chart for visual representation. The programs cover fundamental programming concepts and operations.

Uploaded by

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

Algo N Flow Chart of All EC Programs

The document outlines algorithms and flow charts for eight different programs, including arithmetic and logical operations, data transfer, summation of digits, factorial calculation, square lookup, finding largest/smallest numbers in an array, sorting numbers, and counting bits in memory. Each program includes a step-by-step algorithm and a corresponding flow chart for visual representation. The programs cover fundamental programming concepts and operations.

Uploaded by

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

Program 1: algorithm and flow chart of arithmetic and logical operations.

Algorithm:
1. Start
2. Input two numbers (num1 and num2)
3. Display Menu for user to choose an operation:

 Arithmetic Operations: Addition, Subtraction, Multiplication, Division.


 Logical Operations: AND, OR, NOT (only applied on a single number or
bitwise).
4. Get User Choice.
5. Perform Selected Operation:

 If addition: result = num1 + num2


 If subtraction: result = num1 - num2
 If multiplication: result = num1 * num2
 If division: result = num1 / num2 (handle division by zero)
 If AND operation: result = num1 & num2
 If OR operation: result = num1 num2
 If NOT operation: result = ~num1 or ~num2

6. Display the Result.


7. End.
Flow chart:
Start

Input Num 1 , Num 2

Display the Menu (+,-,*,/,&,|,~)

Get User Choice


(Decision which
Operation ? addition ,
subtraction ,
multiplication….)

Perform Operation
If the choice is ?

Addition(+) then, Multiplication(*) then,


Result=Num1+Num2 Subtraction(-) then, Result=Num1*Num2
Result=Num1-Num2

Display the Result

End
Program 2: Algorithm and Flow chart of Transfer of data from source to
destination.

1. Start the program.


2. Initialize the source memory address (SRC) where the data resides.

3. Initialize the destination memory address (DEST) where data will be transferred.
4. Check if SRC and DEST addresses are valid:
o If valid, proceed.
o If invalid, display an error message and terminate.
5. Retrieve data from SRC:

o Access the memory location.


o Load the value stored in SRC into a temporary variable.
6. Verify if the data was successfully retrieved:
o If the retrieval fails, display an error message and halt or retry.
o If successful, proceed.

7. Store the retrieved data into DEST:


o Write the data from the temporary variable into the destination memory.
8. Verify if the data was successfully stored in DEST:
o If the transfer fails, retry or display an error message.
o If successful, proceed.

9. Perform optional integrity check:


o Compare the original data with the transferred data.
o If they match, the transfer is successful.
o If not, retry the transfer.
10. Display confirmation message that data transfer is completed successfully.

11. End the program.


Start

Flow Chart:
Initialize Source Address (SRC)

Initialize Destination Address (DEST)

Load Data from Source (SRC)

Yes Check if Data is Retrieved No


Successfully? (Y/N)

| (Yes/No Decision)
Proceed Error Handling

Store Data into Destination (DEST)

Verify Transfer (Optional)

Yes Confirm Successful Transfer? No


(Yes/No Decision)

Proceed Retry Transfer

End
Program 3: Sum of first 10 digit number.

Algorithm:

1. Start
2. Initialize a variable to store the sum.
3. Loop through the first 10 digits (1 to 10)
4. Add each number to the sum.
5. Display the final sum
6. End.

Flow chart:

Start

Sum = 0

i = 1 to 10

sum += i

Display sum

End
Program 4: Find a factorial number.

Algorithm:

1. Start
2. Initialize a variable fact to 1.
3. Take input for the number n whose factorial is to be found.
4. Loop from 1 to n.
5. Multiply each number to fact.
6. Display the final factorial value
7. End.

Flow chart: Start

Read n

fact = 1

i = 1 to n

fact *= i

Display the Fact

Ex: 5!=120

5!=120

End
Program 5: Square of number (1 to 10) by using look up table.

Algorithm:

1. Start

2. Define an array (look up table) with squares of numbers from 1 to 10


3. Take input from the user for a number (between 1 and 10).
4. Validate input to ensure it's within the range.
5. Fetch the square from the lookup table.
6. Display the result
7. End.

Start
Flow Chart:

Define Look up Table (1 to 10)

Read n (1-10)

Validate n No

Valid Input? Display Error

Retreive Square Value

Display the Result

End
Program 6: find the largest/smallest number in an array of 32 numbers.

Algorithm:

1. Start

2. Initialize an array with 32 numbers


3. Initialize variables largest and smallest with the first element of the array.
4. Loop through the array:

 If the current number is greater than largest, update largest.


 If the current number is smaller than smallest, update smallest

5. Display the largest and smallest numbers.


6. End.

Flow Chart Start

Define array with 32 values

largest = arr [0]

smallest = arr [FF]

Loop through

array elements

Compare Value with

largest and Smallest

Update values

Display result

End
Program 7: series of 32 bit numbers in ascending/descending order.

Algorithm:

1. Start
2. Initialize an array with 32-bit numbers.
3. Choose the sorting order (ascending/descending).
4. Use Bubble Sort to compare and swap elements:

 Ascending Order: Swap if the left element is greater than the right.
 Descending Order: Swap if the left element is smaller than the right.

5. Display the sorted array.


6. End.

Start
Flow Chart:

Define array with


Numbers

Choose Order

(Ascending / Descendig)

Loop through array elements

Compare vales and swap

Display the Result

End
Program 8: count the number of ones and zeros in two consecutive memory
locations.

Algorithm:
1. Start
2. Initialize variables to store memory addresses and counters for ones and
zeros.
3. Read data from the two consecutive memory locations.
4. Loop through each bit of the data:
a. If the bit is 1, increment the count of ones.
b. If the bit is 0, increment the count of zeros.
5. Display the counts.
6. End.

Start
Flow chart:

Initialize variables

Ones =0 & zero=0

Read memory address

And

Read data from memory

Fetch data from MEM_ADDR1

Fetch data from MEM_ADDR2

Loop through bits

Count ones & zeros

Display counts/results

End

You might also like