1+ /*Programmer-Chase Singhofen
2+ Date-
3+ Specafication- */
4+ //Preproccessor directives
15#include <stdio.h>
26#include <stdlib.h>
37//main function
4- int main ()
5- {
8+ void main () {
69 //Variable Decleration
710 int choice ;
811 float r ,circle ,side ,square ;
@@ -12,30 +15,81 @@ int main()
1215 printf ("Press 2 for area of square\n" );
1316 printf ("Press 3 to CY@\n" );
1417 scanf ("%d" , & choice );
15- 16- if (choice == 1 )
17- {
18+ switch (choice ) {
19+ case 1 :
1820 printf ("Enter the radius.\n\n" );
1921 scanf ("%f" , & r );
2022 circle = 3.14 * r * r ;
2123 printf ("Area of circle is %f\n" , circle );
22- }
23- else if (choice == 2 )
24- {
25- printf ("Enter a side.\n" );
24+ break ;
25+ case 2 :
26+ printf ("Enter a side.\n" );
2627 scanf ("%f" , & side );
2728 square = side * side ;
2829 printf ("Area of square is %f\n" , square );
29- }
30- else if (choice == 3 )
31- {
32- printf ("=======================\n=======================\n=======================\n" );
33- }
34- else
35- {
30+ 31+ break ;
32+ case 3 :
33+ printf ("=======================\n==========CY@==========\n=======================\n" );
34+ system ("pause" );
35+ default :
3636 printf ("you entered incorrect choice.\n" );
37- }
3837
38+ 39+ 40+ }
3941 }
42+ //End main
43+ system ("pause" );
44+ }
45+ 4046
47+ ______________________________________________________________________________________________________________
48+ 49+ /*Programmer Chase Singhofen
50+ Date: 11/4/16
51+ Specifications: Switch : Case 1 ask user for radius of circle
52+ calculate area of circle, display area of circle
53+ case 2 ask for side of square, calculate area of square, display area of square*/
54+ 55+ #include <stdio.h>
56+ #include <stdlib.h>
57+ //main function
58+ void main () {
59+ //Variable Decleration
60+ int choice = 0 ;
61+ float r = 0 , circle = 0 , side = 0 , square = 0 ;
62+ 63+ {
64+ while (choice != 3 ){
65+ printf ("Press 1 for area of circle\n" );
66+ printf ("Press 2 for area of square\n" );
67+ printf ("Press 3 to exit\n" );
68+ scanf ("%d" , & choice );
69+ switch (choice ) {
70+ case 1 :
71+ printf ("Enter the radius.\n" );
72+ scanf ("%f" , & r );
73+ circle = 3.14 * r * r ;
74+ printf ("Area of circle is %f\n" , circle );
75+ break ;
76+ case 2 :
77+ printf ("Enter a side.\n" );
78+ scanf ("%f" , & side );
79+ square = side * side ;
80+ printf ("Area of square is %f\n" , square );
81+ break ;
82+ case 3 :
83+ printf ("program terminated" );
84+ break ;
85+ default :
86+ printf ("you entered incorrect choice.\n" );
87+ break ;
88+ }
89+ }
90+ }
91+ //End main
92+ system ("pause" );
4193}
94+ 95+ +
0 commit comments