Enter a positive number less than 1000 from the keyboard, and output its square root (if the square root is not an integer, output its integer part)//requires checking for a positive number less than 1000 after entering the data, or if it is required to re-enter # include <stdio.h># Include <math.h>int main () {int a;double b;printf ("Enter a positive number less than 1000:"), scanf ("%d", &a), if (a > 0 && A & Lt () {b = sqrt (a);p rintf ("Its square root is:%2.0f\n", b);} elseprintf ("Input data is not in range, please re-enter: \ n"); return 0;}
There is a function://x < 1---y = x 1 <= x <---y = 2 * x-1 x >=---y = 3 * x-11//input x, y#include <stdio.h>int Main () {int x,y;printf ("Please enter X value:"), scanf ("%d", &x), if (x < 1) y = X;else if (x >= 1 && x < ; y = 2 * X-1;elsey = 3 * x-11;printf ("the corresponding Y value is:%d\n", y); return 0;}
Give 100 score, require output grade a,b,c,d,e. 90 points above is a,80~89 bit b,70~79 bit C, 60~69 bit d,60 below is E#include <stdio.h>int main () {int a;printf ("Please enter score:"); scanf ("%d", &a if (a >=) printf ("Rank is a\n"), else if (a >= && a <=) printf ("Rank is b\n"); else if (a >= && a <=) printf ("Rank is c\n"), else if (a >= && a <=) printf ("Rank is d\n"), elseprintf ("rank is e\n"); return 0;}
Give a positive integer not more than 5 bits, require://1, find out it is a few digits//2, respectively output each digit//3, in reverse order output you number # include <stdio.h> #include <math.h>int main () { int A,b,c,d;int count = 1;printf ("Enter a positive integer not more than 5 bits:"), scanf ("%d", &a), C = a;printf ("reverse: \ n"), while (C/10! = 0) {count++; b = c% 10;printf ("%d\n", b); c = C/10;} b = c% 10;printf ("%d\n", b);p rintf ("Number of digits:%d\n", Count);p rintf ("Order: \ n"); while (a% = 0) {d = A/(int) Pow (ten, (count-1));p RI NTF ("%d\n", d); a = a% (int) pow (10,count-1); count--;} return 0;}
The bonuses awarded by the Enterprise are based on the profit percentage. I <= 100000---10% //100000 < I <= 200000---less than 100000 of 10%, higher than 100000 7.5%//200000 < i <= 400000-- -less than 200000 ibid, above 200000 5%//400000 < i <= 600000---higher than 400000 3%,//600000 < i <= 1000000---higher than 600000 1.5%//I > 1000000---More than 1000000 press 1%. Enter the month profit I from the keyboard, the total bonus sum//If statement # include <stdio.h>int main () {int i,j;printf ("Please enter the month Profit:"), scanf ("%d", &i); <= 100000) j = i * 0.1;else if (i > 100000 && i <= 200000) j = 100000 * 0.1 + (i-100000) * 0.075;else if (i > 200000 && i <= 400000) j = 200000 * 0.1 + (i-200000) * 0.05;else if (i > 400000 && i &l t;= 600000) j = 400000 * 0.1 + (i-400000) * 0.03;else if (i > 600000 && i <= 1000000) j = 600000 * 0.1 + (i -600000) * 0.015;elsej = 1000000 * 0.1 + (i-1000000) * 0.01;PRINTF ("Due bonus is:%d\n", j); return 0;}
The bonuses awarded by the Enterprise are based on the profit percentage. I <= 100000---10% //100000 < I <= 200000---less than 100000 of 10%, higher than 100000 7.5%//200000 < i <= 400000-- -less than 200000 ibid, above 200000 5%//400000 < i <= 600000---higher than 400000 3%,//600000 < i <= 1000000---higher than 600000 1.5%//I > 1000000---More than 1000000 press 1%. From the keyboard input month profit I, the total bonus/switch statement # include <stdio.h>int main () {int I,j;int c = i/10000;printf ("Please enter profit:"); scanf ("%d" , &i); if (c >) c = 10;switch (c) {Case 0:j = i * 0.1;break;case 1:100000 * 0.1 + (i-100000) * 0.075;break;case 2: Break;case 3:200000 * 0.1 + (i-200000) * 0.05;break;case 4:break;case 5:400000 * 0.1 + (i-400000) * 0.03;break;case 6: Break;case 7:break;case 8:break;case 9:600000 * 0.1 + (i-600000) * 0.015;break;case 10:1000000 * 0.1 + (i-1000000) * 0 .01;break;default:break;} printf ("Profit is:%d\n", j); return 0;}
Enter 4 integers that require a small to large output of # include <stdio.h>int main () { int a[4]; int i,j; int temp; printf ("Please enter 4 numbers:"); for (i = 0; i < 4; i++) { scanf ("%d", &a[i]); } for (i = 0, i < 4; i++) {for (j = 0; J < (4-i); j + +) if (A[j] > a[j+1]) { temp = A[j ]; A[J] = a[j+1]; A[J+1] = temp; } } printf ("These 4 numbers are arranged in small to large order as follows:"); for (i = 0; i < 4; i++) { printf ("%d", A[i]); } printf ("\ n"); return 0; }
There are 4 of round towers. The center of the Circle is (2,2), ( -2,2), ( -2,-2), (2,-2), the circle radius is 1, the height of the 4 tower is no building outside the 10,//Tower, now enter any point of the coordinates, to find the point of the building height (tower outside the height of 0) #include <stdio.h> int main () {int x,y,h;printf ("Enter X, y:"), scanf ("%d%d", &x,&y), if (x >=-2 && x <= 2 && y >=- 2 && y <= 2) H = 10;elseh = 0;printf ("tower height at this coordinates:%d\n", h);}
"C Language" C program design--rectification--(fourth chapter)--2