Home › Forums › C Programming › calculator programme › Reply To: calculator programme
March 14, 2008 at 9:10 pm
#3263
yeswanth
Participant
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | <br /> #include <stdio.h><br /> #include <conio.h><br /> #include <math.h><br /> main()<br /> {<br /> int a,b,sum,diff,prdct,ch;<br /> double sr;<br /> long sq,cube;<br /> float c,d,ratio;<br /> do<br /> {<br /> clrscr();<br /> printf("t*****Ruel Pagayon Copyright--2007--04--10--*****");<br /> printf("nnntt*****Simple Calculator*****nn");<br /> printf("tt**Operations**n");<br /> printf("ttt*(1)Additionn");<br /> printf("ttt*(2)Subtractionn");<br /> printf("ttt*(3)Multiplicationn");<br /> printf("ttt*(4)Divisionn");<br /> printf("ttt*(5)Squaren");<br /> printf("ttt*(6)Cuben");<br /> printf("ttt*(7)SquareRootn");<br /> printf("nEnter the number of your choice: ");<br /> scanf("%d", &ch);<br /> switch(ch)<br /> {<br /> case 1:<br /> printf("nttEnter two numbers: ");<br /> scanf("%d %d", &a,&b);<br /> sum = a + b;<br /> printf("nnttThe Sum is : %d", sum);<br /> break;<br /> case 2:<br /> printf("nttEnter two numbers: ");<br /> scanf("%d %d", &a,&b);<br /> diff = a - b;<br /> printf("nnttThe Difference is : %d", diff);<br /> break;<br /> case 3:<br /> printf("nttEnter two numbers: ");<br /> scanf("%d %d", &a,&b);<br /> prdct = a * b;<br /> printf("nnttThe Product is : %d", prdct);<br /> break;<br /> case 4:<br /> printf("nttEnter two numbers: ");<br /> scanf("%f %f", &c,&d);<br /> ratio = c / d;<br /> printf("nnttThe Quotient is : %f", ratio);<br /> break;<br /> case 5:<br /> printf("nttEnter a number: ");<br /> scanf("%d", &a);<br /> sq = a * a;<br /> printf("nnttThe Square of %d is : %d", a,sq);<br /> break;<br /> case 6:<br /> printf("nttEnter a number: ");<br /> scanf("%d", &a);<br /> cube = a * a * a;<br /> printf("nnttThe Cube of %d is : %d", a,cube);<br /> break;<br /> case 7:<br /> printf("nttEnter a number: ");<br /> scanf("%d", &a);<br /> sr = sqrt(a);<br /> printf("nnttThe SquareRoot of %d is : %f", a,sr);<br /> break;<br /> }<br /> printf("nnnnntttPress 'x' to quit, any other key to continuen");<br /> }<br /> while (getch() != 'x');<br /> } |