# Can i convert this simple calc to scientific calc?

Page 1 of 1

## 2 Replies - 326 Views - Last Post: 12 December 2012 - 07:17 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=303703&amp;s=4fba33b49808c61c53140afad89ba3aa&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 vilasshende

Reputation: 0
• Posts: 1
• Joined: 12-December 12

# Can i convert this simple calc to scientific calc?

Posted 12 December 2012 - 03:50 AM

```#include<stdio.h>

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

int 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=='+')
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();
}

{
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);
}

```

Is This A Good Question/Topic? 0

## Replies To: Can i convert this simple calc to scientific calc?

### #2 sepp2k

• D.I.C Lover

Reputation: 2271
• Posts: 3,486
• Joined: 21-June 11

## Re: Can i convert this simple calc to scientific calc?

Posted 12 December 2012 - 06:17 AM

Sure you can. I believe in you.

• Saucy!

Reputation: 6207
• Posts: 23,953
• Joined: 23-August 08

## Re: Can i convert this simple calc to scientific calc?

Posted 12 December 2012 - 07:17 AM

Sure, if you can actually program, not just copy & paste code.

EDIT: And that code is broken here:
```scanf("%s",&choice);
```

because choice is a char, not a C-string.

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }