0% found this document useful (0 votes)
250 views3 pages

Algorithm and Flowchart

The document provides algorithms and flow charts for calculating the sum of odd numbers less than 100, the sum of the first n natural numbers, and the area of a triangle using Heron's formula. The algorithm for odd numbers uses a repeat loop to add odd numbers from 1 to 99 in increments of 2. The C program implements this algorithm. The second algorithm calculates the sum of numbers from 1 to a user-input limit n using a for loop. The third algorithm uses Heron's formula to calculate the area of a triangle given the lengths of its three sides.

Uploaded by

joey
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)
250 views3 pages

Algorithm and Flowchart

The document provides algorithms and flow charts for calculating the sum of odd numbers less than 100, the sum of the first n natural numbers, and the area of a triangle using Heron's formula. The algorithm for odd numbers uses a repeat loop to add odd numbers from 1 to 99 in increments of 2. The C program implements this algorithm. The second algorithm calculates the sum of numbers from 1 to a user-input limit n using a for loop. The third algorithm uses Heron's formula to calculate the area of a triangle given the lengths of its three sides.

Uploaded by

joey
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/ 3

ALGORITHS AND FLOW CHARTS

Algorithm to find the sum of all odd numbers less than 100.
Step 1: Start
Step 2: Initialize sum=0
Step 3: Set i=1
Step 4: Repeat steps 4.1 to 4.2 as long as i < 100
Step 4.1: sum = sum + i
Step 4.2: i = i + 2
Step 5: Print sum
Step 6: Stop

Program to find the sum of all odd


numbers less than 100.

#include<stdio.h>
void main()
{
int sum=0, i;
for(i=1;i<100;i=i+2)
{
sum=sum+i;
}
printf("Sum=%d",sum);
}

Algorithm to find the sum of


first n natural numbers.
Step 1: Start
Step 2: Initialize sum=0
Step 3: Read limit and assign it to n
Step 4: Set i=1
Step 5: Repeat steps 5.1 to 5.2 as long as i ≤ n
Step 5.1: sum = sum + i
Step 5.2: i = i + 1
Step 6: Print sum
Step 7: Stop
Algorithm to find the area of a triangle - heron's formula.
Step 1: Start
Step 2: Read length of three sides of a triangle into s1, s2, s3
Step 3: Compute sp = s1+s2+s3/2
Step 4: Compute
Step 5: Print area
Step 6: Stop

Flow Chart to find the area of a triangle - heron's formula.

You might also like