Algorithm-flowchart programs PDF

Title Algorithm-flowchart programs
Author Bhoomesh amaragonda
Course Computer science
Institution Kalinga Institute of Industrial Technology
Pages 10
File Size 325.6 KB
File Type PDF
Total Downloads 32
Total Views 172

Summary

Algorithm-flowchart programs...


Description

Exercise 1. Draw a flowchart to find the area of a triangle when its three sides are given Algorithm Step1:Read a,b,c step2:calculate s=(a+b+c)/2 Step3:Calculate Area=[s*(s-a)*(s-b)*(s-c)]^0.5 Step4:print Area Flowchart

Program #include #include void main() { int s, a, b, c, area; printf("Enter the values of a, b and c \n"); scanf("%d %d %d", &a, &b, &c);

/* compute s */ s = (a + b + c) / 2; area = sqrt(s * (s - a) * (s - b) * (s - c)); printf("Area of a triangle = %d \n", area); }

2. Draw an algorithm and flowchart to reverse a given integer number Algorithm Step1:Read N,s=0 Step2:Repeat Step 3 Until the condition(N>0) is true if the condition is false then goto step4 Step3:calculate s=s*10+N%10 N=N/10 Step4:Output s Flowchart

Program #include int main() { int n, reversedNumber = 0, remainder; printf("Enter an integer: ");

scanf("%d", &n); while(n != 0) { remainder = n%10; reversedNumber = reversedNumber*10 + remainder; n /= 10; } printf("Reversed Number = %d", reversedNumber); return 0; } 3.Write an algorithm and flowchart to find the gcd of two numbers Algorithm: Step1:Read n1,n2,i=1 Step2:Check the condition (i print the value of show Step7:End Flowchart:

Program #include int main() { int i, n, t1 = 0, t2 = 1, nextTerm; printf("Enter the number of terms: "); scanf("%d", &n);

printf("Fibonacci Series: "); for (i = 1; i...


Similar Free PDFs