C language Learning lesson three exercise programming exercises

Source: Internet
Author: User

1, through the experimental method, to observe how the system handles integer overflow, floating point overflow, and floating point overflow situation.

The case of an integer overflow:

#include <stddio.h>int main () {int i=2147483647;printf ("%d%d%d\n", i,i+1,i+2);} The results of the operation are as Follows:

650) this.width=650; "src=" https://s3.51cto.com/wyfs02/M00/9D/10/wKiom1l5lnHR0J9KAABHm4eJeMs529.png "title=" Untitled. PNG "alt=" wkiom1l5lnhr0j9kaabhm4ejems529.png "/>

Explanation: the range of integer i is:

-2147483647-2147483647

So the maximum value plus 1 overflow up and back to the left End.

Floating point Overflow:

Program:

#include <stdio.h>int main () {float toobig=3.4e38*100.0f; printf ("%e\n", toobig);}

Program Results:

650) this.width=650; "src=" https://s3.51cto.com/wyfs02/M00/9D/11/wKioL1l5mQ7AMvjvAAA0QxwCV18900.png "title=" Untitled. PNG "alt=" wkiol1l5mq7amvjvaaa0qxwcv18900.png "/>

Floating-point overflow condition:

#include <stdio.h>int main () {float toosmall=0.1234e-10;printf ("%e\n", toosmall/10);}

Results:

650) this.width=650; "src=" https://s3.51cto.com/wyfs02/M01/9D/11/wKiom1l5nSmQ2rh7AAA_RzAChWc055.png "title=" Untitled. PNG "alt=" wkiom1l5nsmq2rh7aaa_rzachwc055.png "/>

2. Enter a asc| | Code value (66) to output the corresponding Character.

#include <stdio.h>int main () {int i=66;  int j=98; printf ("%c%c\n", i,j);}

Results:

650) this.width=650; "src=" https://s2.51cto.com/wyfs02/M02/9D/12/wKiom1l5n-SzPJxeAAA23GlZ1TY567.png "title=" Untitled. PNG "alt=" wkiom1l5n-szpjxeaaa23glz1ty567.png "/>

3, programming Alarm sound, and output as Follows:

650) this.width=650; "src=" https://s4.51cto.com/wyfs02/M00/9D/14/wKioL1l5sfGiCXQaAAAzw2Zvun0221.png "title=" Untitled. PNG "alt=" wkiol1l5sfgicxqaaaazw2zvun0221.png "/>

The number of/a is the number of alert sounds.

4.

650) this.width=650; "src=" https://s5.51cto.com/wyfs02/M01/9D/15/wKioL1l5uGvxVkJMAAA2MmJ1ywM004.png "title=" Untitled. PNG "alt=" wkiol1l5ugvxvkjmaaa2mmj1ywm004.png "/>

Overflow.


C language Learning lesson three exercise programming exercises

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.