Requirements: 'C' program
Steps: 1.Cpoy the program for my blog to the note pad
2. Then create a seperete note pad file.
3. Now paste this format in your file and open this through ur c program and assign it to your computer ur calculator is ready
(p.s but do understand the program guys)
#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); }
No comments:
Post a Comment