# Can i convert this simple calc to scientific calc?

Page 1 of 1

## 2 Replies - 333 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=e00a5aef4a9a06703e902e68f2799b3b&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: 2277
• Posts: 3,507
• 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: 6219
• Posts: 23,965
• 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.