Correct the code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Correct the code

#include<stdio.h> int main() { char a; printf("Enter your pass"); scanf("%c",&a); if(a== 'Balaji') { printf("password is correct"); } else { printf("Password is wrong"); } }

25th Jan 2021, 8:30 AM
pooja shelage
pooja shelage - avatar
3 Answers
+ 5
Agree with Martin Taylor. You have to use character array to use it as a string and also use strcmp for comparing by including the string header file.Also for a string you have to use double quotation not single quotation mean not 'Balaji' ,it should be "Balaji" https://code.sololearn.com/cA15a630a25a
25th Jan 2021, 8:49 AM
The future is now thanks to science
The future is now thanks to science - avatar
0
In place of chat rewrite it as String. And make necessary changes for it
25th Jan 2021, 8:34 AM
Atul [Inactive]
0
Thanks
30th Jan 2021, 8:06 AM
pooja shelage
pooja shelage - avatar