TCS NQT Set 1 | Day 1 2020 | keyword or not

TCS NQT Set 1 | Day 1 2020 | keyword or not
One programming language has the following keywords that cannot be used as identifiers:
break, case, continue, default, defer, else, for, func, goto, if, map, range, return, struct, type, var
Write a program to find if the given word is a keyword or not
Logic:
- Get the input string from the user
- Then compare all given keywords like break, case, continue, default, defer, else, for, func, goto, if, map, range, return, struct, type and var using strcmp() function
- Then print the output whether the keyword is found or not
TCS NQT Set 1:
Program:
[code lang=”c”]
#include<stdio.h>
#include<string.h>
void main()
{
char a[30];
scanf("%s",&a);
//compare the sting with all keywords
if((strcmp(a,"defer")==0)||(strcmp(a,"if")==0)||(strcmp(a,"for")==0)||(strcmp(a,"return")==0)||(strcmp(a,"break")==0)(strcmp(a,"case")==0)||(strcmp(a,"continue")==0)||(strcmp(a,"default")==0)||(strcmp(a,"else")==0)||(strcmp(a,"func")==0)||(strcmp(a,"goto")==0)||(strcmp(a,"map")==0)||(strcmp(a,"range")==0)||(strcmp(a,"struct")==0)||(strcmp(a,"type")==0)||(strcmp(a,"var")==0))
{
printf("%s is a keyword",a);
}
else //print when keyword not matching
{
printf("%s is not a keyword",a);
}
}
[/code]