this code is not proper work. Code: #include<stdio.h> #include<conio.h> void main() { char n[10],c[10]; clrscr(); printf("enter ur name="); scanf("%s",n); printf("enter ur city name="); scanf("%s",c); if(c=="agra") printf("welcome"); else printf("Bye-Bye"); getch(); }
First: Please use code tags!!! Second: What is wrong with the program? What exactly is wrong with it? Does it compile without warnings/errors? If not please post the exact error messages. What do you expect the program to do? What is it doing? What are you entering when you run the program? Jim
see the changes and comments Code: #include<stdio.h> #include<conio.h>//compiler specific #include<string.h>//add this library int main(){//error 1 never void main always int main() char n[10],c[10]; clrscr();//compiler specific printf("enter your name="); scanf("%s",n);getchar();//always after a scanf printf("enter your city name="); scanf("%s",c);getchar();//always after a scanf if(strcmp(c,"agra")==0)//corect way to compare 2strings. ==0 means 2 strings are equal printf("welcome"); else printf("Bye-Bye"); getch();//compiler specific } compiler specific means that it does not work in all compilers but only in few of them