Message from C, C++ talks

May 2019

β€” πŸ€£πŸ€£πŸ€£

β€” Anyone to assist here on how to calculate the area of a circle by the use of C

β€” Lang

β€” This very easy Brother

β€” 

When it ask a number for the seccond time, it sets zero to all entries of my array instead of the expected result as oyu will see in the code. pls how can i solve it?

β€” #include <stdio.h>
const int MAX=100;
int k=1;
//FILL ROW FOWARD
void FillRowFoward(int A[][MAX], int T, int L, int R, int K){
for (int i = L; i < R; i++)
A[T][i] = K++;
k=K;
}

//FILL COLUMN downward
void FillColumnDownward(int A[][MAX], int T, int B, int R, int K){
for (int i = T; i < B; ++i)
A[i][R-1] = K++;
k=K;
}


//FILL Row Bacward
void FillRowBackward(int A[][MAX], int B, int L, int R, int K){
for (int i = R-1; i >= L; --i)
A[B-1][i] = K++;
k=K;
}

//FILL Column Upward
void FillColumnUpward(int A[][MAX], int T, int B, int L, int K){
for (int i = B-1; i >= T; --i)
A[i][L] = K++;
k=K;
}


//MAIN FUNCTION
int main(void){
int N;
int TOP=0;
int LEFT=0;
int array[MAX][MAX];
do{
printf("enter the Row size or press zerro to quit: ");
scanf("%d", &N);
if(N==0) break;
else{
int BOTTOM=N;
int RIGHT=N;
while(k < N*N){//loop till k isleaa than N*N
//call of FILL ROW FOWARD
FillRowFoward(array, TOP, LEFT, RIGHT, k);
TOP += 1;

//call of FILL COLUMN downward
FillColumnDownward(array, TOP, BOTTOM, RIGHT, k);
RIGHT -=1;
// k +=RIGHT;

//call of FILL Row Bacward
FillRowBackward(array, BOTTOM, LEFT, RIGHT, k);
BOTTOM -=1;
// k +=BOTTOM;

//call of FILL Column Upward
FillColumnUpward(array, TOP, BOTTOM, LEFT, k);
LEFT +=1;
// k +=(BOTTOM -1);
}
int i,j,Lb;
for( Lb=0; Lb<=N; Lb++)
printf("----");
printf("\n");
for ( i=0; i<N; i++){
// printf("\nFFFF");
for ( j=0; j<N; j++)
if(array[i][j]<10)
printf(" %d |", array[i][j]);
else
printf(" %d |", array[i][j]);
printf("\n");
for( Lb=0; Lb<=N; Lb++)
printf("----");
printf("\n");
}
for(int b=0; b<N; b++)
for(int v=0; v<N; v++)
array[b][v]=0;
}}while(N!=0);
return 0;

}

Message permanent page

β€” Here is the output]

β€” As you see,,it works only for the first time.... then later gives garbage... i thnk its a problem of memory. but how do i solve it

Message permanent page

β€” Hello

β€” Welcome

β€” Is reverse function can be used in java without string builder function

β€” Hello and welcome and by the way nice dp, Doraemon!

β€” This chat can’t be used for java questions, read the rules

β€” Sorry

β€” Hi!