Keywords

QUESTION

Teacher is having a list of 10 keywords in C language present in a file. The students has to find a particular keywords along with its position for an ordered list.

ANSWER

#include <stdio.h>
#include<string.h>
int main()
{
  struct keyword
  {
    char key[10];
  }k[15];
  char search[7];
  int i,f=1;
  for(i=0;i<10;i++)
  {
    scanf("%s",k[i].key);
  }
  scanf("%s",search);
  for(i=0;i<10;i++)
  {
    if(!strcmp(k[i].key,search))
    {
      printf("Keyword is %s",search);
      printf("\nposition is %d",i+1);
      f=0;
      break;
    }
  }
   if (f==1)
      printf("Keyword not found");
  
  
	return 0;
}
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock