You are on page 1of 4

FACULTY OF ENGINEERING AND LIFE SCIENCES

DEPARTMENT OF ENGINEERING
ASSIGNMENT 3

• RAMESWARAN GOPAL
NAME • (4183005701)


COURSE CODE • KFS2143

COURSE NAME COMPUTER PROGRAMMING


PUAN. ANIS SABIRIN BT
LECTURER BAHAROM
1.Calculate and display the volume of cylinder given its base radius and height in centimeters

a) Program

• b) Problems inputs

• Radius of base of cylinder (in centimeters)


• Height of cylinder ( in centimeters)

c)Problem outputs

• Volume of cylinder ( in cubic centimeters)


d) C language elements in the volume calculator program

Standard header file #include<stdio.h>

Reserved word int main()

variable float PI = 3.14159265359; /*constant*/ comments

float r, h, volume;// variable//

Standard printf("CALCULATE VOLUME OF CYLINDER(in cm^3)\n"); /* display title */


identifier

printf("\nEnter Radius of the Cylinder(cm)\n");// display radius//

scanf("%f", &r); // user input key required //

printf("Height of the Cylinder(cm)\n"); // display height//

scanf("%f", &h); // user input key required//

volume = PI * r * r * h;// volume formula used//

printf("Volume of Cylinder is %fcm^3\n", volume);//display answer//

Reserved word return (0) ; Punctuation


}
Special symbol

You might also like