Here is my C code:
#include<stdio.h> #include<conio.h> #include<stdlib.h> #include<time.h> const int N = 10; main(){ srand(time(NULL)); int a, b, c, d, i, k, A[N], K[N], j; for(i = 0; i < 10; i++){ A[i] = rand() % 100 - 50; } for(i = 0; i < 10; i++){ printf("%4d", A[i]); } printf("\n"); for(i = 0; i < 10; i++){ if(A[i] < 0){ for(j = 0; j < i; j++){ K[j] = A[i]; printf("%d", K[j]); } } } } What is wrong with him, why he ignores the first negative number and repeatedly displays the same
srand(time(NULL));- alex-rudenkiysrand( (unsigned)time( NULL ) );- alex-rudenkiy