Está en la página 1de 14

PAMANTASAN NG LUNGSOD NGA MAYNIL

(University of the City of Manila)

IN PARTIAL FULLFILMENT IN THE


SUBJECT COMPUTER FUNDAMENTALS
AND PROGRAMMING I FOR COMPUTER
STUDIES DEPARTMENT

SUBMITTED
BY
REY
ES,ANTONI CARLO
2012-10562

SUBMITTED TO
PROFESSOR CHARITO M.
MOLINA

OCTOBER 3, 2013

EXERCISE NO. 3
WRITE A PROGRAM TO READ A NUMBER OF UNITS OF LENGTH (A
FLOAT) AND PRINT OUT
THE AREA OF A CIRCLE OF THAT RADIUS. ASSUME THAT THE VALUE
OF PI IS 3.1416. YOUR OUTPUT SHOULD TAKE THE FORM: THE AREA
OF A CIRCLE OF RADIUS UNITS IS SQUARE UNITS.

ALGORITHM
1. Initialize value pi equals 3.1416
2. Input the value for radius(a).
3. Get the value of area (b) of the circle using the formula b=pi*a*a
4. Print the value of the area of the circle.
5. End of program

CODES
CODING
EXPLANATION
#include <stdio.h>
#include <conio.h>
#define pi 3.1416
float a,b;
main ()
{
printf("Enter the value of lenght/radius:\n");
scanf("%f",&a);
b=pi*a*a;
printf("The area of a circle of radius %f units is %f square units.",a,b);
getch ();
}

CODING
CODING EXPLANATION
EXPLANATION
LINE 1: Declared preprocessor by means of #include<stdio.h>
LINE 2: Declared #include< conio.h>, for getch function
LINE 3: Initialize value of pi to 3.1416
LINE 4: Global declaration of variable a and b as float.
LINE 5: main () function
LINE 6: open curly bracket
LINE 7: print f command to print the word Enter the value of
lenght/radius:
LINE 8: Declared scan f
LINE 9: Declaration of formula for the area of the circle
LINE 10: Print f command to print the value of area of the circle
LINE 11: declared getch()
LINE 12: close curly bracket,end of program.

CODING
EXPLANATION
OUTPUT

CODING
EXERCISE
NO. 1
EXPLANATION
WRITE C PROGRAM TO PERFORM THE CONVERSIONS OF DOLLAR TO
PESO.

ALGORITHM
1. Input value of dollar(a)
2. Get the corresponding value on peso(p) with the formula
p=a*43.36
3. Print the value of peso
4. End of program

COD
CODES
ES
#include <stdio.h>
#include <conio.h>
int a;
float b;
main ()
{
printf("Enter the value of dollar:\n");
scanf("%d",&a);
b=a*43.36;
printf("%d Dollars is equal to %.2f Pesos.\n",a,b);
getch ();
}

CODING
CODING EXPLANATION
EXPLANATION
LINE 1: Declared preprocessor by means of #include<stdio.h>
LINE 2: Declared #include<conio.h> for getch function
LINE 3: Global Declaration of data type and variable a as integer
LINE 4: Global Declaration of data type and variable b as float
LINE 5: main () function
LINE 6: open curly bracket
LINE 7: print f command to print the word Enter the value of dollar:
LINE 8: Declared scan f
LINE 9: Declaration of formula for the conversion
LINE 10: Print f command to print the value in peso
LINE 11: declared getch()
LINE 12: close curly bracket, end of program

CODING
EXPLANATION
OUTPUT

CODING
EXERCISE
NO. 2
EXPLANATION
WRITE A PROGRAM TO READ A FLOAT REPRESENTING A NUMBER
OF DEGREES CELSIUS, AND PRINT AS A FLOAT THE EQUIVALENT
TEMPERATURE IN DEGREES FARENHEIT. PRINT YOUR RESULTS IN A
FORM SUCH AS 100.0 DEGREES CELSIUS CONVERTS TO 212.0
DEGREES FARENHEIT.

ALGORITHM
1. Input value of temperature in degrees Celsius.
2. Get the corresponding value of temperature in degrees
fahrenheit with the formula f=c*9/5+32.
3. Print the temperature value in degrees Fahrenheit.
4. End of program

COD
CODES
ES
#include <stdio.h>
#include <conio.h>
float a,b;
main ()
{
printf("Enter temperature in degrees Celsius:\n");
scanf("%f",&a);
b=a*9/5+32;
printf("%.1f degrees Celsius converts to %.1f degrees Fahrenheit.",a,b);
getch ();
}

CODING
CODING EXPLANATION
EXPLANATION
LINE 1: Declared preprocessor by means of #include<stdio.h>
LINE 2: Declared #include< conio.h> for getch function
LINE 3: Global Declaration of data type and variable a and b as float
LINE 4: main () function
LINE 5: open curly bracket
LINE 6: print f command to print the word Enter temperature in degree
celsius:
LINE 7: Declared scan f
LINE 8: Declaration of formula for the conversion
LINE 9: Print f command to print the value in peso
LINE 10: declared getch()
LINE 11: close curly bracket, end of program.

OUTPUT

También podría gustarte