Why is this program not displayed in order? -- Linux general technology-Linux programming and kernel information. The following is a detailed description. # Include
Int jiafa ();
Int jianfa ();
Int chengfa ();
Float chufa ();
Int main (void)
{Int x;
Char c;
Int y;
Printf ("Welcome to use this little calculator !!! \ N ");
Printf ("Now you can start calculating... \ n ");
Printf ("Input a number: \ n ");
Scanf ("% d", & x );
Printf ("Input a calculating char: \ n ");
C = getchar ();
Printf ("Input anther number: \ n ");
Scanf ("% d", & y );
Switch (c ){
Case 43: {jiafa (x, y );
Break ;}
Case 45: {jianfa (x, y );
Break ;}
Case 42: {chengfa (x, y );
Break ;}
Case 47: {chufa (x, y );
Break ;}
Case 101: {puts ("you want to exit the program, exiting now... \ n ");
Int jiafa (int a, int B)
{Int answer;
Answer = a + B;
Printf ("the answer is: % d \ n", answer );
Return (answer );}
Int jianfa (int a, int B)
{Int answer;
Answer = a-B;
Printf ("the answer is: % d \ n", answer );
Return (answer );}
Int chengfa (int a, int B)
{Int answer;
Answer = a * B;
Printf ("the answer is: % d \ n", answer );
Return (answer );}
Float chufa (int a, int B)
{Float answer;
Answer = a/B;
Printf ("the answer is: % f \ n", answer );
Return (answer );}
I want to write a simple calculator. The above columns are not fully compiled yet, but I have compiled them successfully and the running result is like this:
Welcome to use this little calculator !!!
Now you can start calculating...
Input a number:
3
Input a calculating char:
Input anther number:
5
You put wrong command, try again!
I have been thinking for a long time. Why? So I posted it here. Please take a look at it for me.
I am stupid. If you think my program is ridiculous, do not shoot at me! Ha
Thank you !!!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service