-
int main()
int i,j,k;
i=1; while(i<=100)
for(j=2;jk=i%j;
if(k==0)
continue;
else printf("i=%d\t",i);
i++;Add another parenthesis here, ok
-
k=i%j;
if(k==0) continue;
else printf("i=%d\t",i);}i++;
The procedure in the above paragraph, where I++ should be outside parentheses.
-
#include
int main()
int i,j,k;
i=1; while(i<=100)
for(j=2;jk=i%j;} Braces here.
if(k==0) continue;
else printf("i=%d\t",i);} Braces here.
i++;return 0;
You're not in a loop. If you don't believe you try, let it loop.
-
You should first iterate through the array and find all the elements of the array according to the recursive formula.
Then enter a number to output the corresponding array element value.
When scanf("%d", k) When the return value is EOF, the input is over.
C language** and the result is as follows:
The output conforms to the sample, hope
Source code: include
int main()
int a[30], i, k;
a[0] =0, a[1] =1;
for (i = 2; i < 30;i++) to find the values of all elements of the array.
a[i] =a[i - 1] +a[i - 2];
while (scanf("%d", k) !eof) {eof is the flag for the end of the input.
printf("%d", a[k]);
return 0;
-
First of all, the corresponding exit condition should be set to constant as true attack socks, and then described according to the three cycle patterns of "while loop", "for loop" and "do-while loop".
In this process, it is also necessary to pay attention to managing the loop control variables so that the while condition has a chance to be false, and the beat or hand in the loop body to add break and give it a chance to execute. In addition, it is also possible to set the cycle count variable. In order to prevent the program from having an endless loop, it is best to check the program on your own to ensure that the logic is correct.
If you are not sure, you can set the loop count variable, embed the loop, and stop the program with an error when the upper limit is exceeded. It should be noted that the endless loop should be used as little as possible. If you must use an endless loop, you should also set an exit condition (break) in the loop body.
Key features: C language is a structured language, it has a clear level, can be written in the form of modules, is very conducive to the debugging of the program, and the processing and performance ability of C language is very powerful, relying on a very comprehensive operator and a variety of data types, can easily complete the construction of various data structures, through the pointer type can be directly addressed to the memory and direct operation of the hardware, so it can be used to develop system programs, but also can be used to develop application software.
Let's talk about the difference between foreach and for, foreach is traversal for objects, and there is no need to define the number of loops, but there is a disadvantage, foreach traversal takes read-only data, and cannot add, delete and modify objects in foreach, while for loops can. >>>More
Scope. You static char *chh;
static char *ch1;Although the address pointed to by the two pointers does not change, have you ever wondered whether the memory address they point to has been released, char chc[10]; It's local, the function is out, the lifecycle is over, and you're trying to access it with a pointer in void times(). >>>More
main() [main function main program].
int i,j,k;【Define integer data i,j,k】for(i=1; i<=6;i++) main loop, i from 1 to 6, increasing to 1] for(j=1; j<=20-2*i;j++) subcycle, j from 1 to 20-2*i >>>More
2. 1, True 2, False (there is only one program) 3, False (not necessarily) 4, True. >>>More
C++ is an object-oriented language, not very easy to learn, because it is more flexible, so there are a lot of problems to consider when doing programs! Because of the direct operation of the hardware, it inherits the advantages of the C language, so it is very efficient, and is generally used for the underlying and embedded systems.