C Language Program
1. Multiplication table (using arrays)
# Include <stdio. h>
Int main (void ){
Int a [9];
Int c [9];
Int x;
Int y;
For (x = 1; x <= 9; x ++ ){
A [x] = x;
}
For (y = 1; y <= 9; y ++ ){
C [y] = y;
}
For (x = 1; x <= 9; x ++ ){
For (y = 1; y <= x; y ++ ){
Printf ("% d * % d = % d", a [x], c [y], a [x] * c [y]);
}
Printf ("\ n ");
}
Return 0;
}
2. Implementation of daffodils
# Include <stdio. h>
Int main (void ){
Int a, B, c, sum;
For (a = 1; a <= 9; a ++ ){
For (B = 0; B <= 9; B ++ ){
For (c = 0; c <= 9; c ++ ){
Sum = a * 100 + B * 10 + c;
If (sum = a * a + B * B + c * c ){
Printf ("% d \ n", sum );
}
}
}
}
Return 0;
}
3. Enter the password of a banking system to limit the number of inputs (do... while Statement)
# Include <stdio. h>
Int main (void ){
Int password;
Int count = 0;
Printf ("your password can only be entered three times, more than three times will be locked! \ N ");
Do {
If (count <3 ){
Printf ("enter your password: \ n ");
Scanf ("% ld", & password );
Printf ("Incorrect password, think about \ n ");
}
Else if (3 = count ){
Printf ("wrong password, card to be locked! ");
}
Count ++;
}
While (123456! = Password );
Printf ("go to the banking system !! ");
}
4. A number plus 100 is a worker number plus 168 or a worker number ..
# Include <stdio. h>
Int main (void ){
Long int I, x, y;
For (I = 1; I <100000; I ++ ){
X = sqrt (I + 100 );
Y = sqrt (I + 268 );
If (x * x = I + 100 & y * y = I + 268)
Printf ("\ n % ld \ n", I );
}
}
5. Enter two numbers to calculate the average value
# Include <stdio. h>
Int main (void ){
Int count, sun, anInteger;
Printf ("Enter the inteegers and terminate with negtive number \ n ");
Count = 0;
Sun = 0;
Printf ("Enter number % d:", count + 1 );
Scanf ("% d", & anInteger );
While (anInteger> = 0 ){
Sun + = anInteger;
Count ++;
Printf ("Enter number % d:", count + 1 );
Scanf ("% d", & anInteger );
} If (count! = 0 ){
Printf ("The average is % f \ n", sun/(double) count );
} Else {
Printf ("You enteed no numbers \ n ");
}
Return 0;
}
From 10-3G-He Jinchao