Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Let's code a calculator with C programming! ๐Ÿ–ฉ
Play lesson

C tutorial for beginners โš™๏ธ - Let's code a calculator with C programming! ๐Ÿ–ฉ

4.0 (0)
13 learners

What you'll learn

This course includes

  • 6.5 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

#coding #programming #cprogramming // CALCULATOR PROGRAM char operator = '\0'; double num1 = 0.0; double num2 = 0.0; double result = 0.0; printf("Enter the first number: "); scanf("%lf", &num1); printf("Enter the operator (+ - * /): "); scanf(" %c", &operator); // clear \n from input buffer printf("Enter the second number: "); scanf("%lf", &num2); switch(operator){ case '+': result = num1 + num2; break; case '-': result = num1 - num2; break; case '*': result = num1 * num2; break; case '/': if(num2 == 0){ printf("You can't divide by zero!\n"); } else{ result = num1 / num2; } break; default: printf("Invalid operator\n"); } printf("result: %.4lf", result); return 0;

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere