Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 21-03-2009
Member
 
Join Date: Mar 2009
Posts: 1
Calculator in C programming

Hi

I am searching Calculator codes in C programming. If know Calculator coding in C programming plz provide me. I tried to make code but giving me error.


Thanks
Reply With Quote
  #2  
Old 21-03-2009
Member
 
Join Date: Oct 2008
Posts: 54
Re: Calculator in C programming

I am having this Calculator code

Code:
#include<stdio.h>

float add(float,float);
float sub(float,float);
float product(float,float);
float divide(float,float);

void main()
{
    float n1,n2;
    char sym,choice;
    printf("This Program is a program for calculator\n\n");
    scanf("%f%c%f",&n1,&sym,&n2);
    if(sym=='+')
        printf("\n%f",add(n1,n2));
    if(sym=='-')
        printf("\n%f",sub(n1,n2));
    if(sym=='*')
        printf("\n%f",product(n1,n2));
    if(sym=='/')
        printf("%f",divide(n1,n2));
    printf("\nDo you wish to continue[y/n]");
    scanf("%s",&choice);
    if(choice=='y'||choice=='Y')
        main();
}

float add(float m1,float m2)
{
    return(m1+m2);
}

float sub(float m1,float m2)
{
    return(m1-m2);
}

float product(float m1,float m2)
{
    return(m1*m2);
}

float divide(float m1,float m2)
{
    return(m1/m2);
}
Reply With Quote
  #3  
Old 21-03-2009
Member
 
Join Date: Oct 2008
Posts: 73
Re: Calculator in C programming

Code:
#include <stdio.h><br>
#include <conio.h><br>
main()<br>
{<br>
  float n1,n2,s,d,p,q;<br>
  clrscr();<br> 
  printf("\n Enter two nos");<br>
  scanf("%f%f"&n1,&n2);<br>
  s=n1+n2;<br>
  d=n1-n2;<br>
  p=n1*n2;<br>
  q=n1/n2;<br>
  printf("\n Sum %f",s);<br>
  printf("\n Difference %f",d);<br>
  printf("\n Product %f",p);<br>
  printf("\n Quotient %f",q);<br>
  getch();<br>
 return(0);<br>
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Calculator in C programming"
Thread Thread Starter Forum Replies Last Post
Java Calculator (Not GUI) trixsareforkids Software Development 1 07-04-2011 02:48 AM
How to keep calculator always on top in windows 7 Zhankana_n Operating Systems 3 04-12-2009 10:16 AM
Socket programming: Is any new Programming Language? Kushan Software Development 3 14-11-2009 11:13 AM
Replace calculator with Command Line Calculator Eric B Windows Software 3 07-05-2009 04:32 PM
JetBrains Introduces a New Programming Paradigm With its Meta Programming System JoeFrat Software Development 3 13-12-2008 01:49 PM


All times are GMT +5.5. The time now is 03:23 PM.