CALCULATORCode CrazeJan 29, 20231 min read#include <stdio.h>int main() { float num1, num2; char operator; printf("Enter two numbers: "); scanf("%f %f", &num1, &num2); printf("Enter an operator (+, -, *, /): "); scanf(" %c", &operator); switch(operator) { case '+': printf("%.1f + %.1f = %.1f", num1, num2, num1 + num2); break; case '-': printf("%.1f - %.1f = %.1f", num1, num2, num1 - num2); break; case '*': printf("%.1f * %.1f = %.1f", num1, num2, num1 * num2); break; case '/': printf("%.1f / %.1f = %.1f", num1, num2, num1 / num2); break; default: printf("Invalid operator"); } return 0;}
#include <stdio.h>int main() { float num1, num2; char operator; printf("Enter two numbers: "); scanf("%f %f", &num1, &num2); printf("Enter an operator (+, -, *, /): "); scanf(" %c", &operator); switch(operator) { case '+': printf("%.1f + %.1f = %.1f", num1, num2, num1 + num2); break; case '-': printf("%.1f - %.1f = %.1f", num1, num2, num1 - num2); break; case '*': printf("%.1f * %.1f = %.1f", num1, num2, num1 * num2); break; case '/': printf("%.1f / %.1f = %.1f", num1, num2, num1 / num2); break; default: printf("Invalid operator"); } return 0;}
Stack Using QueueA stack can be implemented using two queues in C. The basic idea is to use one queue for enqueue operations and another for dequeue...
Queue Using StackA queue can be implemented using two stacks in C. The basic idea is to use one stack for enqueue operations and another for dequeue...
Queue Using Array#include <stdio.h> #include<stdlib.h> #include<math.h> #define size 5 int queue[size]; int front = -1; int rear = -1; void enque(void);...
Comments