Advance Calculator with C

libre lait hahaha hirap pala ng C di gaya ng mga ordinary computer langauge kailangan accurate ang i store mo na mga data type hehhe


C:
#include <stdio.h>
#include <math.h>

int main(){
    int chossen = 0;
    float pi = 3.141593;


    while (chossen != 6){
    printf("==== ADVANCE CALCULATOR ====\n");
    printf("1. Circle(area and circumference).\n");
    printf("2: Triangle (area using Heron's formula).\n");
    printf("3: Rectangle (area and perimeter).\n");
    printf("4: Sphere (volume and surface area).\n");
    printf("5: Pythagorean theorem (find hypotenuse).\n");
    printf("6: Exit.\n");

    
    while(chossen < 1 || chossen > 6){
    printf("Please Choose to the menu:");
    scanf("%d",&chossen);
        if(chossen < 1 || chossen > 6 ){
            printf("Negative Value or Zero or more than the Me nenu is not Valid.\n");
        }
    }

        if(chossen == 1 ){
            float radius= 0.0f;

            ///while loop para ma check kung negative ito or positive///
            while(radius < 1){               
            printf("please enter radius:");
            scanf("%f", &radius);
               if(radius <= 0){
                printf("Radius cannot be in negative or Zero.\n");
               }
            }
            printf("Circle with radius %.2f:\n",radius);
            printf("Area: %.2f square units.\n",pi * pow(radius,2) );
            printf("Circumference: %.2f units.\n", 2 * pi * radius);
            return 0;
        }

        if(chossen == 2){
            float a = 0.0f;
            while (a < 1){
            printf("Please input variable a in (a + b + c):");
            scanf("%f",&a);
                if(a <= 0){
                    printf("Variable A cannot be negative or Zero\n");
                }

            }
            
            float b = 0.0f;
            while (b < 1){
            printf("Please input variable b in (a + b + c):");
            scanf("%f",&b);
                if(b <= 0){
                    printf("Variable B cannot be negative or Zero\n");
                }

            }
            
            float c = 0.0f;
            while (c < 1){
            printf("Please input variable c in (a + b + c):");
            scanf("%f",&c);
                if(c <= 0){
                    printf("Variable C cannot be negative or Zero\n");
                }

            }
            
            float semiperimeter = (a + b + c)/2;
            printf("The semiperimeter is %.2f meters\n", semiperimeter);
            double Area;
            float multiplyall;
            multiplyall = semiperimeter * (semiperimeter - a) * (semiperimeter - b) * (semiperimeter - c);
            Area = sqrt(multiplyall);
            printf("The Area is %.11lf meterssquared\n", Area);
            return 0;

        }

        if(chossen == 3){
            float length = 0.0f;
            float width = 0.0f;

            while (length < 1){
                printf("Please input value for length:");
                scanf("%f",&length);
                    
                    if(length <= 0){
                    printf("Variable length cannot be negative or Zero\n");
                    }
            }

            while (width < 1){
                printf("Please input value for width:");
                scanf("%f",&width);
                    
                    if(width <= 0){
                    printf("Variable width cannot be negative or Zero\n");
                    }
            }

            printf("Area is: %.2f\n",length * width);
            printf("Perimeter is: %.2f\n",2 * (length + width));
            return 0;
            
        }
        if(chossen == 4){
          float radius = 0.0f;
          float volume = 0.0f;
          float surfacearea = 0.0f;
          while(radius < 1){
            printf("Please Input Radius:");
            scanf("%f", &radius);
              if(radius <= 0){
                printf("Variable Radius cannot be negative or Zero\n");
              }
          }
            
          volume = 4.00/3.00 * (pi * pow(radius,3));
          surfacearea = 4 * (pi * pow(radius,2));
          printf("Volume is %.2f\n",volume);
          printf("Surface Area is %.5f\n",surfacearea);
          return 0;

        }
        if(chossen == 5){
            float a = 0.0f;
            float b = 0.0f;
            
              while(a < 1){
                printf("Please input For variable A:");
                scanf("%f", &a);
                  if(a <= 0 ){
                    printf("Variable A cannot be Negative Value or Zero\n");
                  }
              }
                          
              while(b < 1){
                printf("Please input For variable B:");
                scanf("%f", &b);
                  if(b <= 0 ){
                    printf("Variable A cannot be Negative Value or Zero\n");
                  }
              }
              
              float findsqrt = pow(a,2) + pow(b,2);
              printf("Hypotenuse is %f", sqrt(findsqrt));
              return 0;
        }

    } //end ito ng while loop///

}

need kasi maintindihan ang C lalo kung plano mag malware developer ehh kasi halos need to para makipag communicate ca hardware at need ma understand how Computer working di gaya ng ibang Computer Language hehhe
 
Ang iyong C code para sa advance calculator ay maganda at detalyado. Ito ay may mga menu para sa iba't ibang calculations tulad ng circle, triangle, rectangle, sphere, at Pythagorean theorem. Mayroon kang mga validation checks para sa mga input ng user, tulad ng pag-check kung negative o zero ang input para sa mga radius, sides ng triangle, length, width, at iba pa.

Napansin ko na pagkatapos mong mag-compute ng isang calculation sa bawat menu option, ginagamit mo ang return 0; statement. Ito ay nagreresulta sa pagtapos kaagad ng program pagkatapos ng isang calculation, kaya hindi na maaaccess ang iba pang menu options. Maaari mong tanggalin ang return 0; sa bawat calculation block para ma-maintain ang program na tumatakbo hanggang sa piliin ng user na mag-"Exit" sa menu.

Dagdag pa, maaari mong isaayos ang pagkakabasa ng input sa pamamagitan ng paglagay ng break; sa bawat if(chossen == ...) block sa halip na gamitin ang return 0;. Ito ay magpapahintulot sa user na mag-choose ng iba pang menu options pagkatapos matapos ang isang calculation.

Kung balak mong gumawa ng mas malaking project sa C programming, maganda ang practice na itong pagiging detalyado at pagkakaroon ng validation checks para sa inputs. Patuloy na pag-aralan ang mga concepts sa C programming at paggamit ng mga functions tulad ng scanf, printf, pow, at sqrt ay makakatulong sa iyo na maging proficient sa pag-develop ng mga applications sa C.
 
Ang iyong C code para sa advance calculator ay maganda at detalyado. Ito ay may mga menu para sa iba't ibang calculations tulad ng circle, triangle, rectangle, sphere, at Pythagorean theorem. Mayroon kang mga validation checks para sa mga input ng user, tulad ng pag-check kung negative o zero ang input para sa mga radius, sides ng triangle, length, width, at iba pa.

Napansin ko na pagkatapos mong mag-compute ng isang calculation sa bawat menu option, ginagamit mo ang return 0; statement. Ito ay nagreresulta sa pagtapos kaagad ng program pagkatapos ng isang calculation, kaya hindi na maaaccess ang iba pang menu options. Maaari mong tanggalin ang return 0; sa bawat calculation block para ma-maintain ang program na tumatakbo hanggang sa piliin ng user na mag-"Exit" sa menu.

Dagdag pa, maaari mong isaayos ang pagkakabasa ng input sa pamamagitan ng paglagay ng break; sa bawat if(chossen == ...) block sa halip na gamitin ang return 0;. Ito ay magpapahintulot sa user na mag-choose ng iba pang menu options pagkatapos matapos ang isang calculation.

Kung balak mong gumawa ng mas malaking project sa C programming, maganda ang practice na itong pagiging detalyado at pagkakaroon ng validation checks para sa inputs. Patuloy na pag-aralan ang mga concepts sa C programming at paggamit ng mga functions tulad ng scanf, printf, pow, at sqrt ay makakatulong sa iyo na maging proficient sa pag-develop ng mga applications sa C.
pwede kaya sya sa malware development? magagamit ko kaya sya sa cybersecurity course ko?
 
pwede kaya sya sa malware development? magagamit ko kaya sya sa cybersecurity course ko?
Ang C programming language ay isang versatile language na maaaring gamitin sa iba't ibang fields tulad ng cybersecurity at malware development. Ang pagkakaroon ng proficiency sa C programming ay magiging advantageous sa cybersecurity courses at sa pag-develop ng tools para sa security analysis at research.

Sa pag-develop ng malware, ang C language ay karaniwang ginagamit dahil sa kanyang kakayahan na direktang makipag-ugnayan sa hardware at operating system ng isang computer. Maaari kang gumawa ng mga malware na mas mabisa at mas advanced gamit ang C dahil sa control at flexibility na ibinibigay nito sa developer.

Sa cybersecurity courses, ang pagkakaunawa sa C programming ay magiging mahalaga dahil ito ang base language ng maraming tools at applications na ginagamit sa field ng cybersecurity. Ito ay makakatulong sa iyo na maunawaan ang inner workings ng mga security tools at protocols, at maipatupad ang mga security best practices.

Maaari mong gamitin ang iyong advance calculator project bilang stepping stone para ma-enhance ang iyong C programming skills at ma-apply ito sa mga security-related projects. Patuloy na pag-aralan ang advanced concepts sa C, security principles, at ethical häçking techniques para maging proficient sa cybersecurity field at malware development.
 
Nag simula paku nang college,C Ang unang programming language aking tunan,na isip ko din itong idea

Galing
 

About this Thread

  • 6
    Replies
  • 379
    Views
  • 3
    Participants
Last reply from:
0zner

Trending Topics

Online now

Members online
1,038
Guests online
1,547
Total visitors
2,585

Forum statistics

Threads
2,273,387
Posts
28,949,158
Members
1,235,726
Latest member
Tempest21
Back
Top