Now, I'll try to show how to print number, with input from keyboard, and yield something like this:
Please enter number between 1-20: 10 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 1 2 3 4 5 6 7 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 10
We can write the algorithm in C, like this:
/* Algoritm01 Sept 30, 2009 http://therudi.com compile using GNU GCC Compiler. */ #include<stdio.h> int main(void){ int A, B, Input; printf("Please enter number between 1-20: "); scanf("%d", &Input); for (A = 1; A <= Input; A = A + 1){ for (B = 1; B <= A; B = B +1){ printf("%d ", B); } printf("\n"); } return 0; getchar(); }
0 comments:
Post a Comment