can you please solve and run the program Problem 2: in the following the C funct
ID: 3683004 • Letter: C
Question
can you please solve and run the program
Explanation / Answer
#include <stdio.h>
#define NR 100
#define NC 100
#define NCC NR*NC
void cc(char arr[NR][NC], int locations[NCC][2], char ch, int* count){
int i,j,k=0;
for(i=0;i<NR;++i){
for(j=0;j<NC;++j){
locations[k][0]=i;
locations[k][1]=j;
k++;
if(ch==arr[i][j])
(*count)++;
}
}
}
int main(){
char arr[NR][NC]={{'a','b','c'},{'c','a','d'},{'s','e','a'}};
int locations[NCC][2];
int count=0;
char ch;
printf("Enter the character you want to search: ");
scanf("%c",&ch);
cc(arr,locations,ch,&count);
printf("Number of entered character found is: %d ",count);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.