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

STRUCTURED PROGRAMMING

The document contains various C programming code snippets demonstrating structured programming concepts, including calculations for the area and volume of geometric shapes such as rectangles, triangles, cylinders, circles, and spheres. It also includes examples of control structures like while loops, for loops, and switch statements for grading. The code snippets contain several syntax errors and formatting issues that would need to be corrected for proper execution.

Uploaded by

orabrian511
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

STRUCTURED PROGRAMMING

The document contains various C programming code snippets demonstrating structured programming concepts, including calculations for the area and volume of geometric shapes such as rectangles, triangles, cylinders, circles, and spheres. It also includes examples of control structures like while loops, for loops, and switch statements for grading. The code snippets contain several syntax errors and formatting issues that would need to be corrected for proper execution.

Uploaded by

orabrian511
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

STRUCTURED PROGRAMMING

Area Of A Rectangle Area Of A Triangle


#include<stdio.h> #include<stdio.h>
Main() Main()
{ {
Int area, length, width; Int area, base, height;
Length=5; Base=10;
Width=6; Height=4;
Area=length*width; Area=0.5*base*height;
Printf(“The area of rectangle is:”,area); Printf(“The area of a triangle is:%d”,area);
} Return 0;
}

Volume Of A Cylinder
#include<stdio.h>
#define 3.114 PI
Main ()
{
Int volume, radius, height;
radius=21;
Height=20;
Printf(“enter the radius of the cylinder\n”);
Scanf(%of”,radius);
Printf(“enter the height of the cylinder\n”);
Scanf(“%of”,height);
Volume=PI*radius*radius*height;
Printf(“volume is %*2f cm squared”, volume;
Return 0;
}

Area Of A Circle
#include<stdio.h>
#define PI 3.14
Main()
{
Float radius,area;
Printf(“enter the radius of the circle\n”);
Scanf(“%f”,&radius);
Area=PI*radius*radius;
Printf(“area is %.2f cm squared”,area);
Return0;}
Area Of A Cylinder(2(PI)RH+2(PI)RR) Volume Of A Sphere(4/3(PI)RRR)

#include<stdio.h> #include<stdio.h>

#define PI 3.14 #define . PI 3.14

Main(){ Main(){

Float radius, height,area ; Float radius, volume;

Printf(enter the radius of the cylinder\n”); Printf(“enter the radius of the sphere”)

Scanf(“%f”, &radius); Scanf(“%f”,& radius)

Printf(“enter th height of the cylinder \n”); Volume=1.33*PI*radius*radius*radius;

Scanf(“%f”,& height); Printf(“volumeis %.2f cm cubic”, volume);

Area=2*PI*radius*height+2*PI*radius*radius; Return 0;

Printf(“area is %.2f cm squared”, area); }

Return 0;}

WHILE-LOOP
0-5 11-89

#include<stdio.h> #include<stdio.h>

Main(){ Main(){

Int count; Int count;

Count=0; Count==11;

While(count<6){ While(count<89){

Printf(“rhe value of the count is %d/n”, count); Printf(“the value of count is %d/n”, count);

Count=count+1 Count=count+1;

}} }}

Other On Break Put Continue 0-9 39-23 skipping 31

#include<stdio.h> #include<stdio.h>

Main(){ Main(){

For (i=0;i<10;i++){ Int I;


If( i=4 ){ For(i=39;i.22;i--){

Break; If(i==31){

} Continue;}

Prinyf(“%d\n”, i); Printf(“%d\n”, i);

}} }}

GRADING

#include<stdio.h> ARRAY

Void main(){ #include<stdio.h>

Chargrade Int main()

Printf(“enter your gradee:”); Int n [10];

Scanf(“%C”, & grade); Int i, j;

Switch(grade){ For(i=0; i <10; 1++){

Case’A’: n [i]=I +100;

Printf(“excellent!\n”); for(j=0; j<10; j++){

Break; printf(“element [%d]=%d\n, j, n [j];

Case’B’: }

Printf(“very good!\n”);}} Return 0; }

You might also like