February 4, 2011

Simple Calculator in C



//Program for Calculator
#include<stdio.h>
#include<conio.h>
void main()
{
float n1,n2;
char c,s;
clrscr();
printf("Enter the Values for Calculation [e.g:1+2]\n\n");
scanf("%f%c%f",&n1,&c,&n2);
if(c=='+')
printf("\n%f",n1+n2);
if(c=='-')
printf("\n%f",n1-n2);
if(c=='*')
printf("\n%f",n1*n2);
if(c=='/')
printf("\n%f",n1/n2);
printf("\nDo you wish to Continue[y/n]");
scanf("%s",&s);
if(s=='y'||s=='Y')
main();
}

Hope you liked my posts, give comments if you have any doubts.. :)

Related Posts :



Categories:

2 comments:

Can You Help Me

To understand the Concept of File I/O.
Post on your blog

This small pdf of schaum series will help u..

http://www.mediafire.com/?aqa1am71x5y1a57
password: mycfiles.com

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Related Posts with Thumbnails