C language for some simple operation exercises.
Swap two numbers:
# include <stdio.h>int main (void) {int i = 3;int j = 5;int t;//Exchange The value of I with j T = I;i = J;j = t;printf ("i =%d, j =%d\n", I, j); return 0;}
Output Pyramids of any character at any level:
# Include<stdio.h>main () {int a,i,j; char c; printf ("Please enter pyramid layer, 30: \ n"), scanf ("%d", &a); printf ("Enter the characters to be output: \ n "); scanf ("%c", &c); for (i=a;i>0;i--) { printf ("%*s", I, ""); For (j=0;j< (A-i) *2-1; j + +) { printf ("%c", c); } printf ("\ n"); } return 0;}
Operation Result:
Operation:
# include <stdio.h>int main (void) {/*float i;i = 51/4;printf ("%f\n", i);p rintf ("%d%d%d%d%d\n", 3%3, 13%-3,-13 %3, -13%-3, -13%23, 3%5); */int m;int k = 10;m = (21>3) && (k=5),//m is Boolean, K=5 is true, False if and only if k=0, that is, 0 is false, other numbers are true printf ("M =%d, k=%d\n ", M, k);//When the left cannot determine the true and false value of M, the right side is executed; If the left side can determine the true and false m value, the right does not execute. && the left expression is false, the expression on the right will definitely not execute//| | When the expression on the left is true, the expression on the right will definitely not execute return 0;}
Three numbers sorted by:
# include <stdio.h>int main (void) {Double I, J, k;printf ("Please enter three numbers (separated by a space):"); scanf ("%lf%lf%lf", &i, &j, &A mp;k), if (i > J) {if (i > K) {printf ("Max:%lf\n", i), if (J > K) printf ("The size order of the number is:%lf >%lf >%lf\n", I, J, K); elseprintf ("The size order of the numbers is:%lf >%lf >%lf\n", I, K, j);} else{printf ("Max:%lf\n", K), if (i > J) printf ("The size order of the number is:%lf >%lf >%lf\n", K, I, J); elseprintf ("The size order of the number is:%lf > %lf >%lf\n ", K, J, I);}} Else{if (J > K) {printf ("Max:%lf\n", J), if (i > K) printf ("Size Order of the number:%LF >%lf >%lf\n", J, I, K); elseprintf ("Number of the large Small order:%lf >%lf >%lf\n ", J, K, I);} else{printf ("Max:%lf\n", K), if (i > J) printf ("The size order of the number is:%lf >%lf >%lf\n", K, I, J); elseprintf ("The size order of the number is:%lf > %lf >%lf\n ", K, J, I);}} return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Getting Started with C programming-program practice (bottom)