Answer to Question #204936 in C for Ali khan

Question #204936

Write a program that search a string from multidimensional array of characters. 


1
Expert's answer
2021-06-09T07:42:02-0400
#include<stdio.h>
#include<stdlib.h>
#include <string.h>




int main( void){
	char languages[5][20] = {"Java", "Python", "C++", "C programming", "SQL"};
	int i,index=-1;
	char targetLanguage[20];
	printf("Enter the language to search: ");
	gets(targetLanguage);


	for(i=0;i<5;i++){
		if(strcmp(targetLanguage,languages[i])==0){
			index=i;
		}
	}
	if(index!=-1){
		printf("\nThe language exists in the array.\n\n");
	}else{
		printf("\nThe language does NOT exist in the array.\n\n");
	}


	getchar();
	getchar();
	return 0;
}





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS