In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use C language to achieve simple calculator functions". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn "how to use C language to achieve simple calculator functions" together.
Simple calculator, simple addition, subtraction, multiplication and division function, select the corresponding operator output operator corresponding number, and then input we want to calculate the two numbers, the program will give the calculation results.
effect demonstration
Simple Calculator Code/* Simple Calculator name:zsh */ #include //simple calculator void menu() //operator display interface { printf("-----------------------------------\n");printf("Please enter your choice\n");printf("1. + \n"); printf("2. - \n"); printf("3. * \n"); printf("4. / \n"); printf("--------------------------------------------\n");}int main(){ int i = 0; int j = 0; int num = 0; //Save calculation results int select = 0; //store the selected operator do { menu(); //Print operator display interface scanf("%d", &select); //Enter operator number printf("Please enter the calculated value"); scanf("%d%d", &i, &j); //Enter operand value switch (select) { case 1: printf("%d+%d=%d\n", i, j, num=i+j); //addition break; case 2: printf("%d-%d=%d\n", i, j, num=i-j); //subtraction break; case 3: printf("%d*%d=%d\n", i, j, num=i*j); //multiplication break; case 4: printf("%d/%d=%d\n", i, j, num=i/j); //Division operation break; default: printf("Please select again! "); break; } } while(select); return 0; } Thank you for reading, the above is "how to use C language to achieve simple calculator function" content, after the study of this article, I believe that everyone on how to use C language to achieve simple calculator function this problem has a deeper understanding, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.