Please fix this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Please fix this?

I want to input some text(number +letters) in to my c program. example: input= ab123( leter+number ) and i want to use it in conditional statement How To fix this include<stdio.h> Int main() { char a; scanf("%c",&a); If(a='12ab'|| a='12AB') { printf( "code is correct"); } return 0; }

28th Sep 2020, 12:23 AM
Kavishanka Kodithuwakku
1 Answer
+ 8
Your first mistake u forget #(hash) in headerfile your int main int should be in small letter . after that where you write if condition here u used assignment operator this is wrong u have to give exact condition . You cannot assign values in u should use == double equal to . In c and cpp single quotes and double quotes have difference to single quotes denote char and double string you define char a and in if condition u wrote '12ab' this is invalid . This is string you should write it on double quotes 'a' char and this "12ab" is string . Next you cannot compare string directly in c and cpp you should use strcpy() function for comparison.
28th Sep 2020, 1:25 AM
A S Raghuvanshi
A S Raghuvanshi - avatar