Sign Up

Talk Programming , Career, Mental Health, Talk Personal Finance ❤️‍ Post a query and receive responses ✅

Have an account? Sign In


Have an account? Sign In Now

Sign In

Post a query and receive responses. Ask anything, Ask Mitra ❤️‍

Sign Up Here


Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.


Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.


Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Ask Mitra

Ask Mitra Logo Ask Mitra Logo

Ask Mitra Navigation

  • Home
  • About Us
  • Find Jobs
  • Blogs
    • Add New Blog !
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Ask a Question
  • Home
  • All Categories
  • Find Jobs
  • Points and Swags
    • Badges and Points
    • Ask Mitra Swags
  • Blog
    • Add New Blog !
  • FAQs
  • Community Members 💓
  • About Us
  • Contact Us
Home| Questions|Q 62868
Next
Closed
Samip
SamipBeginner
Asked: July 2, 20222022-07-02T12:22:48+05:45 2022-07-02T12:22:48+05:45In: Programming

Calculator in C

  1. ?I am trying to make a calculator in C. Is there any way to make GUIs? If not, then, is there any way to make compiler understand arthematic symbols? I mean, the user can enter 5+3*6  or anything like this and there should be the correct output. If both of them aren’t possible then what stuffs can make a calculator look kinda professional?
    Answers are appreciated with thanks.
c++
  • 1
  • 3 3 Answers
  • 65 Views
  • 0 Followers
  • 0
Share
  • Facebook

    Related Questions

    • What is wrong here??
    • Need to find if the array contains same number certain times consecutively.
    • I have to submit my C project due by tomorrow but graphics.h isn't working,why?
    • WAP To find any term of fibonacci series using recursion
    • WAP to convert AD Data to BC data (using structure) using C and C++

    You must login to add an answer.


    Forgot Password?

    Need An Account, Sign Up Here

    3 Answers

    • Voted
    • Oldest
    • Recent
    • Random
    1. Best Answer
      Virtual Wiz Tech Nerd Love to Code | Just a Tech Enthusiast
      2022-07-02T16:36:44+05:45Added an answer on July 2, 2022 at 4:36 pm

      wel achieving what you intend is not exactly impossible but it is a rather cumbersome task…

      for gui look alike you can use boarders and alignment made of //”‘:_-+*# but you eill still have to manually enter the input from keyboard

      now for your arithmetic operations it is simpler to use only 2 numbers and one operator or multiple inputs but same operator….or you can try

      • using the getchar() function to read
      • compare the input character using ascii value to know whether it is an operand or an operator.
      • store the operands and operators in two diff arrays
        (store operands as integers ie, 1,2,3etc and operators as the ascii value).
      • then do the calculations for the operators with corresponding operands.

      but this all may result in magic number errors so i suggest you avoid that

      you can stick with a simpler calculator as i have said at the beginning of this answer

      below is example of a simple calculator using switch case:

      
      

      #include <stdio.h>

      int main() {

      char op;
      double first, second;
      printf("Enter an operator (+, -, *, /): ");
      scanf("%c", &op);
      printf("Enter two operands: ");
      scanf("%lf %lf", &first, &second);

      //using %.1lf to limit input with only one place decimal value
      switch (op) {
      case '+':
      printf("%.1lf + %.1lf = %.1lf", first, second, first + second);
      break;
      case '-':
      printf("%.1lf - %.1lf = %.1lf", first, second, first - second);
      break;
      case '*':
      printf("%.1lf * %.1lf = %.1lf", first, second, first * second);
      break;
      case '/':
      printf("%.1lf / %.1lf = %.1lf", first, second, first / second);
      break;
      // operator doesn't match any case constant
      default:
      printf("Error! operator is not correct");
      }

      return 0;
      }

       

       

      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    2. tathya Beginner
      2022-07-02T20:59:12+05:45Added an answer on July 2, 2022 at 8:59 pm

      Its better to make it simple calculator  but yeah go through this links it will help you.

      http://freesourcecode.net/cprojects/82590/sourcecode/CALC.CPP#.YsBf9c3BXxM

      https://mobile.happycodings.com/c//beginners-lab-assignments/code1.html

      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    3. Notabhishekrai Explainer Just a guy with great mustache.
      2022-07-02T21:18:46+05:45Added an answer on July 2, 2022 at 9:18 pm

      C does provide GUI ya know.

      Checkout GTK toolkit.

      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    Sidebar

    Ask A Question

    Your Favourite Topics

    • Announcements
    • Blockchain
    • Books

        • —Non Tech Books
        • —technical books
    • Business and Entrepreneurship
    • Careers
    • College
    • Content and Blog
    • CyberSecurity
    • Design and Arts
    • Devices and Gadgets
    • Digital Marketing
    • Entertainment

        • —Movies-Series-TV
        • —Music
        • —Sports
    • Events
    • For Admins only.
    • Health

        • —Fitness
    • Money

        • —Personal Finance
        • —Stock Market
    • Operating System

        • —linux
        • —windows
    • Other
    • Paid Internship
    • Programming

        • —AI/ML
        • —APIs
        • —C & C#
        • —Django
        • —Flutter
        • —Go
        • —HTML&CSS
        • —Java
        • —JavaScript
        • —Mobile Apps Development
        • —Node Js
        • —NoSQL
        • —Php
        • —Python
        • —React JS
        • —SQL

    Stats

    • Questions 1k
    • Answers 10k
    • Best Answers 391
    • Users 2k

    Top 6 Members This Month

    Vicky

    Vicky

    • 0 Questions
    • 78 Points
    Sensei
    puppet

    puppet

    • 0 Questions
    • 23 Points
    Beginner
    wtfixair

    wtfixair

    • 0 Questions
    • 22 Points
    Beginner
    Dhanmaya

    Dhanmaya

    • 0 Questions
    • 20 Points
    Beginner
    Riyesh

    Riyesh

    • 0 Questions
    • 20 Points
    Beginner
    pranitkarki

    pranitkarki

    • 0 Questions
    • 20 Points
    Beginner

    Trending Tags

    askmitra blockchain c++ career coding College cybersecurity Django Flutter help javascript laptop laravel linux poll Programming python question react web web development wordpress
    • Popular
    • Answers
    • Rounak Agrawal

      Ask Mitra Udemy Courses Giveaway

      • 76 Answers
    • Subedi Bibek

      The Complete JavaScript Course 2022: From Zero to Expert! Udemy ...

      • 73 Answers
    • Subedi Bibek

      Mega Giveaway at askmitra.com 🔥

      • 69 Answers
    • bishwaKiran
      bishwaKiran added an answer Try getting into githubs student program, use your university/collage/school ID… January 30, 2023 at 7:44 pm
    • Sandeep Poudel
      Sandeep Poudel added an answer SOLVED: It was due to unfinished SSL certificate installation January 27, 2023 at 7:11 pm
    • Aashutosh_k
      Aashutosh_k added an answer Software piracy protection system Fingerprint voting system Stock price prediction… January 26, 2023 at 7:37 pm

    Related Questions

    • How to join 100day challenge in Data science project

      • 0 Answers
    • Hi I am doing my major project using CNN. Can ...

      • 0 Answers
    • Can you guys suggest some projects for my final year ...

      • 1 Answer
    • Low end emulator of android studio

      • 2 Answers
    • Can someone briefly explain me difference between Hot reload and ...

      • 2 Answers

    Explore

    • Home
    • Trending Category
      • Programming
      • Web Development
      • —Mobile Apps Development
      • —Stock Market
      • Business and Entrepreneurship
      • Blockchain
      • College
      • —Personal Finance
      • —HTML&CSS
      • —JavaScript
      • —Python
      • —React JS
      • —Node Js
      • —C & C#
      • Content and Blog
      • Careers
    • All Categories
      • Go to All Categories
      • Health
      • —Go
      • —Flutter
      • Digital Marketing
      • —APIs
      • Devices and Gadgets
    • Find Job and Internships
    • Points and Swags
      • Badges and Points
      • Ask Mitra Swags
    • All Blogs
      • Add New Blog !
    • FAQs
    • Community Members 💓
    • Questions
      • Un Answered
      • New Questions
      • Most Seen Questions
      • Most Answered
      • Trending Questions
    • Tags

    Footer

    Ask Mitra

    Ask Mitra

    Ask Mitra is a social question and answer engine that will assist you in forming a community and connecting with others. Talk about programming, your career, your mental health, and your personal finances. ❤️‍ Post a query and receive responses ✅

    Quick Navigation

    • Ask a Question
    • Home
    • All Categories
    • Find Jobs
    • Points and Swags
      • Badges and Points
      • Ask Mitra Swags
    • Blog
      • Add New Blog !
    • FAQs
    • Community Members 💓
    • About Us
    • Contact Us

    Legal Stuff

    • Terms of use and policy