Total Pageviews

Sunday, 3 July 2016

"strcmp" C- Example

Input- red
Output-Its a Dusk

Input-green
Output-Its a Dawn

Input- #Any other Color
Output-Invalid Input

--Program--

#include<stdio.h>
int main()
{
char s[20];
scanf("%s",&s);
if(strcmp(s,"blue")==0)
printf("Its a Dawn");
else if(strcmp(s,"red")==0)
printf("Its a dusk");
else printf("Invalid Input");
return 0;

}

OUTPUT


No comments:

Post a Comment