Introduction to C Programming--Program practice (ON)

Source: Internet
Author: User

You can tap to write the following practice code, to see the results of the operation, are very simple, the key to understand.


If

# include <stdio.h>int main (void) {int i = 1;i = i + 1;if (i>10); i = 1;printf ("%d\n", I); return 0;}


If Example 2:

# include <stdio.h>int main (void) {int i;if (1 > 2) printf ("Haha! \ n "), else if (2 > 5) printf (" Hey! \ n "), else if (2 > 2) printf (" SKDF "), Else i = 1 > 2;printf (" i =%d ", i); return 0;} /* Summary: Even if multiple expressions are true, only the first expression will be executed */


scanf Example 1:

# include <stdio.h>int main (void) {int I, J, k;//printf ("Input: Value of I"), scanf ("%d%d", &i, &j, &k);p rintf ( "I =%d\nj =%d\nk =%d\n", I, J, K); return 0;}

scanf Example 2:

# include <stdio.h>int main (void) {int I;char ch;printf ("Enter value for I: i="), scanf ("%d", &i);p rintf ("result is: i=%d\n", i) while ((Ch=getchar ()) = ' \ n ') continue;int j;printf ("Please enter the value of J: j="), scanf ("%d", &j);p rintf ("Result: j=%d\n", j); return 0;}


Storage of floating-point numbers:

# include <stdio.h>int main (void) {float x = 66.6;printf ("x =%f\n", x); return 0;}

BOOL Variable:

# include <stdio.h>int main (void) {bool I;i = true;//1 is true, 0 is false. printf ("%d\n", I); return 0;}


Fetch address character &:

# include <stdio.h>int main (void) {Double i = 12314;printf ("% #X \ n", &i);  Outputs the address of the variable i in 16 binary form return 0;}




Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Introduction to C Programming--Program practice (ON)

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.