Search
 
SCRIPT & CODE EXAMPLE
 

C

Calculator_C

#include <stdio.h>
#include <math.h>
#include <string.h>

int main()
{   
    char answer[10];
    char dump;
    printf("Welcome To Cli Calculator
Made by Argha Datta
");
    
    do
    {
        char inputUser;
        float num1, num2, result;
        printf("Please enter your state of operation: ");
        scanf("%c",&inputUser);
    
        printf("Enter the first operand: ");
        scanf("%f",&num1);
        printf("Enter the second operand: ");
        scanf("%f",&num2);
        switch (inputUser)
        {
        case '+':
            printf("The Addition of %f and %f is %f
",num1,num2,num1+num2);
            break;
        case '-':
            printf("The Subtraction of %f and %f is %f
",num1,num2,num1-num2);
            break;
        case '*':
            printf("The Multiplication of %f and %f is %f
",num1,num2,num1*num2);
            break;
        case '/':
            printf("The Division of %f and %f is %f
",num1,num2,num1/num2);
            break;
        case '^':
            printf("The Result of %f ^ %f is %f
",num1,num2,powf(num1,num2));
        default:
            printf("Invalid Operation,please try again!
");
            break;
        }
        printf("Do you want to run it again(if yes ,type yes or type no for exit) :");
        scanf("%s",answer);
        dump = getchar();

    } while (strcmp(answer,"yes")  == 0);
    
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: how to shutdown system c++ 
C :: fonction recursive successeur nombre chaine de caractere en c 
C :: postgres random select 
C :: #![feature]` may not be used on the // stable release channel 
C :: cannot get / react router dom 
C :: c 2d array dimensions 
C :: strcasecmp in c 
C :: A binary tree whose every node has either zero or two children is called 
C :: if statement c short form 
C :: print bool c 
C :: svg not loading in chrome 
C :: c static variables 
C :: connect servo to arduino 
C :: c# for loop decrement 
C :: c modify char array 
C :: c int 
C :: how to delete virtual hard disk virtualbox 
C :: c fopen 
C :: add_to_cart how to call it woocommerce 
C :: fwrite in c 
C :: c program that replace vowels in a string with char 
C :: DrawText() raylib 
C :: convert string to int c 
C :: c program for swapping of two numbers 
C :: size of pointer in c 
C :: c to fahrenheit 
C :: prime numbers 
C :: finding characters in string 
C :: boolean operators in c++ 
C :: hostbuilder add environment variables 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =