Simple Calculator Program In C

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.ย. 2024
  • technotip.com/6...
    We are using else-if clause in this program.
    We display list of operation one can perform. That is,
    1. Addition
    2. Subtraction
    3. Multiplication
    4. Division
    We ask the user to input his / her choice for arithmetic operation. If the user selects 1, then we ask the user to enter 2 integer numbers to perform addition operation. Once the user enters 2 integer numbers we add and display the result on the screen
    C Programming: Beginner To Advance To Expert
    technotip.com/6...

ความคิดเห็น • 5

  • @pkmcalicut
    @pkmcalicut 2 ปีที่แล้ว +2

    Bro i have copied your code to do a simple calculation
    But my eclipse is not running properly
    Only when i entered the choice and the 2 numbers
    The text ” enter your choice “ is coming including the result
    What to do

    • @UchihaItachi-sv5uq
      @UchihaItachi-sv5uq ปีที่แล้ว

      try this if this work thank me only work on c compiler
      #include
      int main(){
      char operator;
      double num1;
      double num2;
      double num3;
      double num4;
      double num5;
      double result;
      printf("
      Enter an operator (+ - * /): ");
      scanf("%c", &operator);
      printf("Enter number 1: ");
      scanf("%lf", &num1);
      printf("Enter number 2: ");
      scanf("%lf", &num2);
      printf("Enter number 3: ");
      scanf("%lf", &num3);
      printf("Enter number 4: ");
      scanf("%lf", &num4);
      printf("Enter nember 5: ");
      scanf("%lf", &num5);
      switch(operator){
      case '+':
      result = num1 + num2 + num3 + num4 + num5;
      printf("
      result: %lf", result);
      break;
      case '-':
      result = num1 - num2 - num3 - num4 - num5;
      printf("
      result: %lf", result);
      break;
      case '*':
      result = num1 * num2 * num3 * num4 * num5;
      printf("
      result: %lf", result);
      break;
      case '/':
      result = num1 / num2 / num3 / num4 / num5;
      printf("
      result: %lf", result);
      break;
      default:
      printf("%c is not valid", operator);
      }
      return 0;
      }

  • @aslammohamed970
    @aslammohamed970 4 ปีที่แล้ว

    👌🏻👌

  • @user-re9kh7kb7r
    @user-re9kh7kb7r ปีที่แล้ว

    bhai apna channel band kardo please
    tumse na ho payega

    • @satishb4945
      @satishb4945 ปีที่แล้ว +1

      Kya hua Bhai? Accha khasa to hai.
      I've been following the video and notes on the blog and it's better than 90% of the materials online!