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

Pseudocode PDF

1. The document contains three sample problems that provide pseudocode and C code to solve basic computational problems. 2. The first problem calculates the area of a circle with a radius of 1 unit. 3. The second problem calculates the sum, average, and product of three input numbers. 4. The third problem finds the largest of three numbers input by the user.

Uploaded by

neojohn05
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)
371 views3 pages

Pseudocode PDF

1. The document contains three sample problems that provide pseudocode and C code to solve basic computational problems. 2. The first problem calculates the area of a circle with a radius of 1 unit. 3. The second problem calculates the sum, average, and product of three input numbers. 4. The third problem finds the largest of three numbers input by the user.

Uploaded by

neojohn05
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

Sample Problem A

The radius of a circle equal to one unit. Write a pseudocode to compute the corresponding area of the circle
and print out the value of the radius and the area.

Pseudocode:
1. START
2. Initialize radius (R), the value of PI=3.1415, and AREA.
3. Calculate the area of the circle, AREA=PI*R*R.
4. Print out the value of radius and its corresponding area.
5. STOP


C Program
#include <stdio.h>
#include <conio.h>
main()
{
int R=1;
const float PI=3.1416;
AREA=0;
clrscr();
AREA=PI*R*R;
printf("\n The radius is %i",R);
printf("\n The area is %f",AREA);
getch();
return 0;
}

Sample Problem B:

Given the three numbers A, B, and C. Write a pseudocode to compute and print out the sum, the average, and
the product of these values.

Pseudocode:

1. START
2. Initialize A, B, C, SUM, AVE and PRO.
3. Read in the values of A, B, and C.
4. Determine the sum of the three values read (SUM=A+B+C).
5. Compute the average by dividing the sum by 3 (AVE=SUM/3).
6. Multiply the first value by the second value then by the third value to determine the product of the three
values (PRO=A*B*C).
7. Print out the computed values (sum, average, and the product).
8. STOP

C Program
#include <stdio.h>
#include <conio.h>
main()
{
int A=0;
int B=0;
int C =0;
int SUM=0;
float AVE=0;
int PRO=0;
clrscr();
2. Initialize radius (R), the
value of PI=3.1415, and
AREA.

3. Calculate the area of the circle, AREA=PI*R*R.
4. Print out the value of radius and its corresponding area.

2. Initialize A, B, C, SUM, AVE and PRO.

A=3;
B=5;
C=8;
SUM=A+B+C;
AVE=SUM/3;
PRO=A*B*C;
printf("\n The sum is %i",SUM);
printf("\n The average is %fi",AVE);
printf("\n The product is %i",PRO);
getch();
return 0;
}


Sample Problem C:

Write a pseudocode to find the largest among three different numbers entered by user.

Pseudocode:

1. START
2. Initialize a, b, c, LNUM.
3. Read the values of a, b, and c.
4. Compare a and b If (a>b)
5. Compare a and c If(a>c)
6. The largest number is a (LNUM=a)
7. Else
8. The largest number is c (LNUM=c)
9. Else
10. Compare b and c If (b>c)
11. The largest number is b (LNUM=b)
12. Else
13. The largest number is c (LNUM=c)
14.
15. STOP

C Program
#include <stdio.h>
#include <conio.h>
main()
{
int a=0;
int b=0;
int c=0;
int LNUM=0;
clrscr();
printf("Enter the first number :");
scanf("%i",&a);
printf("Enter the second number :");
scanf("%i",&b);
printf("Enter the third number ");
scanf("%i",&c);
if (a>b)
{
if (a>c)
{
LNUM=a;
3. Read in the values of A, B, and C.

4. Determine the sum of the three values read (SUM=A+B+C).
5. Compute the average by dividing the sum by 3 (AVE=SUM/3).
6. Multiply the first value by the second value then by the third
value to determine the product of the three values (PRO=A*B*C).

7. Print out the computed values (sum, average, and the product).

2. Initialize a, b, c, LNUM.

3. Read the values of a, b, and c.

4. Computer a and b If (a>b)

5. Compare a and c If(a>c)
6. The largest number is a
(LNUM=a)

}
else
{
LNUM=c;
}
}
else
{
if (b>c)
{
LNUM=b;
}
else
{
LNUM=c;
}
}

printf("The largest number is %i",LNUM);
getch();
return 0;
}
7. The largest number is c (LNUM=c)
10. Compare b and c If (b>c)

11. The largest number is b (LNUM=b)
12. The largest number is c (LNUM=c)

You might also like