Source Programs in C Language Programming Lectures Chapter 1 C1_301.C main () {int n, p; for (n = 1;;; +) {p = n * n + N + 41; ("% d, P =% D", n, p); if (s (p) = 0) Printf ("ok\ n"); else {printf ("error. \ n"); break; } }} s (v) int v; {int j; if (v < 2) return (- 1); for (j = 2; J < v; j + +) if (v% J = 0) return (- 1); return (0); } The second chapter C201.C main () {int I = 32767; printf (" ni=% D", I + 1); getch (); } C202.C Main () {long int i; i=1; printf("\n 1!=%d",i); i=2*i; printf("\n 2!=%d",i); i=3*i; printf("\n 3!=%d",i); i=4*i; printf("\n 4!=%d",i); i=5*i; printf("\n 5!=%d",i); i=6*i; printf("\n 6!=%d",i); i=7*i; printf("\n 7!=%d",i); i=8*i; printf("\n 8!=%d",i); i=9*i; printf("\n 9!=%d",i); i=10*i; printf("\n10!=%d",i); Getch (); } C203.C main () {float a = 1.2345678, B = 1.12345670; printf ("n na=% 12.10f", a); printf ("\ nb=% 12.10f", b); Getch (); } C204.C main () {char a, b, c, d, e, f; a=&apos; 5&apos;; b=&apos; 60&apos;; c=&apos; 101&apos;; d=&apos; xe&apos;; e=&apos; x41&apos;; Printf ("a=% C b=% c=% c=% c=% C d=% C e=% c\ n", "a, b, c, d, e"); Getch (); } C2_301.C main() {int I = 2, J = 1, k; k = I + + + j; Printf (" n n I =% D J =% d k =% d n", i, j, k); Getch (); printf (" n 101 1"); getch (); } The third chapter C3_401.C # include "stdio. h" main () {char a=&apos;A&apos;; printf ("% c n", putchar (a))); Getch (); } C3_402.C # include "stdio. h" main () {char a []= "abcdef"; printf ("% c\ n", put (a)); getch (); } C3_403.C main() {int I = 12; float x = 1.3; Printf (" n%4d n%-4d n%10.5f n%-10.5f") I, i, x, x; getch (); } C3_404.C main() {int I = 12; float x = 1.3; Printf (" n% 4d n% 04d n% 10.5f n% 010.5f") I, i, x, x; getch (); } C3_405.C main() {char s []= "ABC"; printf (" n% s n% 5.3s", s, s); Getch (); } C3_406.C main() {int I = 123; long J = 123456789; float x = 1.1234567890; double y = 1.12367890; printf (" n% d n% ld n% 12.10f n% 12.10lf"), I, j, x, y; getch (); } C3_407.C main() {int a = 567; char c = 65; char s []= "ABC"; float x = 567.789; printf (" n% d n% x n% o n% u", a, a, a), printf (" n% c n% s", c, s); printf ("\ n% f\ n% e \ n%, g", x, x, x); Getch (); } C3_408.C # include "stdio.h" main () {char c; int i; For (i = 1; (c = getchar ()!=&apos; n&apos;; I + +) printf (" nChar is% C."), c); Getch (); } C3_409.C main() {int a, b, c; Scanf ("% d% d% d", & a, & b, & c); printf ("% d% D", a, b, c); Getch (); } C3_410.C main () {int i; float a; scanf ("% 5f% 4d", & a, & i); printf ("a=% f I =% d n", "a, i); Getch (); } C3_411.C main() {int i, j; printf (" n1:% d", n2:% d","% d","% d", & i, & j))); getch (); } C3_412.C # include "stdio.h" Main () {char c; While ((c = getch ())!= 13) {if (c > = 65 & & C < = 90 | | C > = 97 & & C < = 122) {c = C + 5; if (c > 90 & & C < 97 | C > 122) C = c-26; putchar (c); } } getch (); } C3_601.C # define printt (x, y, z) printf ("x=% d, y=% d, z=% d n, x, y, z) Main () {int x, y, z; x = y = z; x = y = z = z = 2; ++x ||++ ++|+++++++++++++ +++++|++++|++++|+ +++++|++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ ++++++++z; printt (x, y, z, printt (x, y, Z + + z; printt (x, y, z); x = y = z = - 2; + + X & & + + Y & + + z; printt (x, y, z); } C3_602.C # define PRINT (x) printf ("% d n", x) # include < stdio. H > main () {int x = 1, y = 1, z = 0; x = x & Y | | z; PRINT (x); PRINT (x | |! Y + + & + + z); PRINT (y); PRINT (z); x = y = 1; z = x + - 1; PRINT (x); PRINT (z); Z += - x ++ + y; PRINT (x); PRINT (z); PRINT (y); } C3_603.C # define PRINT (X) printf ("% d n", X) # include < stdio. H > main () {int x = 3, y = 2, z = 1; x = y + >= X & & X - y == + z; PRINT (x); PRINT (y); PRINT (z); y *= z = x + (z + 2); PRINT (x); PRINT (y); PRINT (z); X = y = z = 1; PRINT (- X & & & + y | | Z ++); PRINT (x); PRINT (y); PRINT (z); X = 9; y = 6; z = 5; X= (x + y)% Z >= x% Z + y% z?? 1: 0; PRINT (x); } The fourth chapter C4_101.C include <stdio.h> main() {int a, b, max; printf ("Input A and b="); scanf ("% d%", & a, & b); if (a > b) max = a; else max = b; Printf ("The max of a a n d b:% d n", max); } C4_101B.C # include < stdio. H > main () {int a, b, max; printf ("Input A and b="); scanf ("%d", & a,& b); Max = a; if (max < b) max = b; Printf ("The max of a a n d b:% d n", max); } C4_103.C # include < stdio. H > main () {int x, y; Printf ("Enter integer X and Y:"); scanf ("% d%", & x, & y); if ("x!= y") If (x > y) printf ("X > Y\ n"); else printf ("X < Y\ n"); else printf ("X = Y\\ n"); } C4_105.C # inc

docxDoc C Language Programming Source Code

Professional Docs > Common > Other > Preview
35 Pages 0 Downloads 66 Views 3.0 Score
Tips: Current document can only be previewed at most page8,If the total number of pages in the document exceeds page 8,please download the document。
Uploaded by admin on 2019-10-15 12:02:10
Rate
You can enter 255 characters
What is my domain?( answer:www.45doc.com )
comments
  • No comments yet