Question: Rewrite the following code in C language WITHOUT USING THE string.h library and WITHOUT USING pointers please. the output should stay the same provide a
Rewrite the following code in C language WITHOUT USING THE string.h library and WITHOUT USING pointers please. the output should stay the same
provide a screenshot of the new code
code to rewrite it below .
#include #include int covid_sd(char classroom[][6],int num_rows,char* fst){ int count =0; int flag=1; char lst[18]; int ff[18]={0}; for (int i=0; i=0){ if (classroom[i-1][j] != 'X' && classroom[i][j]!='X' && ff[count]==0 && lst[count-1]!=classroom[i][j] ) {*(lst+count)=classroom[i][j]; ff[count]=1; flag = 0; count +=1; } } if (i+1=0){ if (classroom[i][j-1] != 'X' && classroom[i][j]!='X' && ff[count]==0 && lst[count-1]!=classroom[i][j]) {*(lst+count)=classroom[i][j] ; ff[count]=1; flag = 0; count +=1;} } if (j+1<6){ if (classroom[i][j+1] != 'X' && classroom[i][j]!='X' && ff[count]==0 && lst[count-1]!=classroom[i][j]) {*(lst+count)=classroom[i][j] ; ff[count]=1; flag = 0; count +=1;} } } } lst[count]='\0'; strcpy(fst,lst); return flag; } int main(){ char classroom[][6]={"AXHXnX","XqIXeK","bXXJXE"}; int num_rows = 3 ; char fst[18]; printf("%d ",covid_sd(classroom,num_rows,fst)); printf("the elements which violte are %s",fst); }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
