Friday, February 25, 2011
0
C Program Language (Skip Count by 3 and 5)
I was asked by my teacher to create a program using while repetition statement skip counting by 3 and skip counting by 5. Thinking how to create it I was puzzled first on how to accomplish my task. To create the program I must think first the different ways on how to solve the program and I figured out the solution.
Now check this program skip counting by 3.
Here is the codes of the program skip counting by 3.
#include<stdio.h> #include<conio.h> int main() { int x; x=3; while (x <= 48) { if(x == 3){ x=x-2; printf("%d ",x); } else{ x = x + 3; printf("%d ",x-1); }} getch(); }
Now check the program below using the skip counting by 5. I used the do while repetition statement in creating the program.
The codes for skip counting by 5.
#include<stdio.h> #include<conio.h> main() { int x; x=5; do { if(x==5){ x=x-4; printf("%d ",x);} else{x=x+5; printf("%d ",x-1); } } while (x<=50); getch(); }
The repetition statement is very important in programming it is all due because it is being used by a programmers to loop the program simultaneously. Hope this program can help you on how to used the repetition statement.
Subscribe to:
Post Comments (Atom)
0 Responses to “C Program Language (Skip Count by 3 and 5)”
Post a Comment