0% found this document useful (0 votes)
28 views

#Include Void: 1.

The document contains 8 code snippets written by Bryan Liew Fei Shiang. Each snippet contains a C program to input numeric values from the user, perform basic mathematical calculations on the values (e.g. addition, subtraction, multiplication), and output the result. The calculations include computing the area of a triangle, perimeter of a circle, area of a circle, sum of numbers, difference of numbers, years since entering a program, square of a number, and multiplication of numbers.

Uploaded by

dinagkar6
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

#Include Void: 1.

The document contains 8 code snippets written by Bryan Liew Fei Shiang. Each snippet contains a C program to input numeric values from the user, perform basic mathematical calculations on the values (e.g. addition, subtraction, multiplication), and output the result. The calculations include computing the area of a triangle, perimeter of a circle, area of a circle, sum of numbers, difference of numbers, years since entering a program, square of a number, and multiplication of numbers.

Uploaded by

dinagkar6
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

//<BRYAN LIEW FEI SHIANG> //<15DET12F1012>

#include <stdio.h> void main () { float length, width, area; printf ("Please enter length :"); scanf ("%f",&length); printf ("Please enter width :"); scanf ("%f",&width); getchar();

area = 0.5 * length * width; printf ("Area of triangle is %f cm",area); getchar();

2.//<BRYAN LIEW FEI SHIANG> //<15DET12F1012>

#include <stdio.h> #define PI 3.142 void main () { float perimeter, radius; printf ("Please enter radius :");

scanf ("%f",&radius); getchar();

perimeter = 2 * PI * radius;

printf ("The perimeter for circle is : %f cm.", perimeter); getchar();

3.//<BRYAN LIEW FEI SHIANG>


//<15DET12F1012>

#include <stdio.h> #define PI 3.142 void main () { float radius, area; printf ("Please enter radius :"); scanf ("%f",&radius); getchar();

area = PI * radius*radius;

printf ("Area for circle is : %f cm.", area); getchar();

4.//<BRYAN LIEW FEI SHIANG>


//<15DET12F1012>

#include <stdio.h> void main() { float n1, n2, n3, n4, total; printf ("Please enter number 1 :"); scanf ("%f",&n1); printf ("Please enter number 2 :"); scanf ("%f",&n2); printf ("Please enter number 3 :"); scanf ("%f",&n3); printf ("Please enter number 3 :"); scanf ("%f",&n4); getchar();

total = n1 + n2 + n3 + n4;

printf ("Total number is : %f .",total); getchar();

5. //<BRYAN LIEW FEI SHIANG>


//<15DET12F1012>

#include <stdio.h> void main() { float n1, n2, diff; printf ("Please enter number 1 :"); scanf ("%f",&n1); printf ("Please enter number 2 :"); scanf ("%f",&n2); getchar();

diff = n1 - n2;

printf ("Difference for 2 number is : %f .",diff); getchar();

6. //<BRYAN LIEW FEI SHIANG>


//<15DET12F1012>

#include <stdio.h> void main() { float n1, year, diff; printf ("Year you enter PSAS :"); scanf ("%f",&n1); getchar();

diff = 2013 - n1;

printf ("Total year you have been in PSAS : %f .",diff); getchar();

7. //<BRYAN LIEW FEI SHIANG>


//<15DET12F1012>

#include <stdio.h> void main() { float n1, square; printf ("Please enter number 1 :"); scanf ("%f",&n1); getchar();

square = n1*n1;

printf ("Square for number is : %f .",square); getchar();

8. //<BRYAN LIEW FEI SHIANG>


//<15DET12F1012>

#include <stdio.h> void main() { float n1, n2, n3, total; printf ("Please enter number 1 :"); scanf ("%f",&n1); printf ("Please enter number 2 :"); scanf ("%f",&n2); printf ("Please enter number 3 :"); scanf ("%f",&n3); getchar();

total = n1 * n2 * n3;

printf ("Total multiplication is : %f", total); getchar();

You might also like