Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/articles/c-tutorials/)
-   -   Calculator program in C (http://www.go4expert.com/articles/calculator-program-c-t689/)

Deucel 14Feb2011 12:26

Re: Calculator program in C
 
Quote:

Originally Posted by 143rocker (Post 5548)
sorry for that reply....this is the real one

Code:

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


Thanks, and it is good, but...
To give the program some readability:

Code:

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


Naveed Marwat 1Mar2011 11:39

Re: Calculator program in C
 
Nice Sharing

alexsmth114 11Mar2011 10:18

Re: Calculator program in C
 
Excellent post, couldn't have asked for more!!..

sura 27Oct2011 04:38

Re: Calculator program in C
 
very good
i also like this ..
its good...

rioeduardo 18Feb2013 08:13

Re: Calculator program in C
 
Thanks for sharing.


All times are GMT +5.5. The time now is 14:52.