C_68 C program to Compare two Strings | with strcmp() and without strcmp() function

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ม.ค. 2025

ความคิดเห็น • 193

  • @shivendra3019
    @shivendra3019 3 ปีที่แล้ว +128

    Syntax of first line in Jenny's lecture: "In the series of programming in C we had discussed (most recent topic name), Thank you very much mam, even village people can understand your quality lectures which helps us to become a digital citizen. # Jenny's lectures for life.

    • @persiasprince
      @persiasprince 2 ปีที่แล้ว +3

      Yeah so what's the problem in it if we put && operation and it will also reduce the time complexity
      If && condition not true then simply print "not equal" .

    • @jayashreesahoo1027
      @jayashreesahoo1027 2 ปีที่แล้ว +3

      In the series of learning programming in c..... 😊

  • @indrajitmandal5985
    @indrajitmandal5985 ปีที่แล้ว +6

    14:14 mam says :-"samajh rahe ho"
    Was 🥰🥰💕
    First time Hindi sune mam
    Love from West Bengal, India ❣️❣️❣️

  • @rickk3300
    @rickk3300 3 ปีที่แล้ว +68

    11:39 it will return a negative value since the ASCII value of 'e' is smaller than that of 'i'.

  • @boukefmohamed3191
    @boukefmohamed3191 2 ปีที่แล้ว +8

    I couldn’t have done it without you ... So thanks ( from algeria ).

  • @CarolErva
    @CarolErva 2 ปีที่แล้ว +11

    I'm transitioning to IT and I love your lessons, one of the few out there that I can really understand everything. Thank you for your great work, ma'am!

    • @CodeNest_1703
      @CodeNest_1703 2 ปีที่แล้ว

      th-cam.com/video/fNIwsgoTiqw/w-d-xo.html

    • @Md.MahinUddin-fi5gy
      @Md.MahinUddin-fi5gy 6 หลายเดือนก่อน

      22.4

    • @kv5539
      @kv5539 4 หลายเดือนก่อน

      @@CarolErva Did you transition?...How is the experience in IT?..I also wish to transit from electrical engineer to IT

  • @jeanrioux8750
    @jeanrioux8750 2 ปีที่แล้ว +24

    20:20 Using the condition with &&, if length of S1 < length of S2 and the first characters of S2 = S1, then the strings will be considered to be the same. Ex. S1 = "Me" and S2 = "Meat". The reason is that as soon as the Null character of S1 is encountered, the program will skip the loop, so the comparison with the remaining characters of S2 will not occur and the flag will never be changed to 1.

  • @Gupatik
    @Gupatik 2 ปีที่แล้ว +2

    Great Indian ppl have really conquered the programming world. respect!!

  • @rickk3300
    @rickk3300 3 ปีที่แล้ว +6

    Thank you ma'am for this amazing explanation....got the concept of comparing two strings very nicely..✌🏻✌🏻

  • @vishu3766
    @vishu3766 2 ปีที่แล้ว +16

    /*Compare two Strings*/
    #include
    #include
    int main()
    {
    int value;
    char s1[] = "Hello";
    char s2[] = "Hey";
    value = strcmp(s1,s2);
    if (value == 0)
    {
    printf("Same");
    }
    else
    {
    printf("Not same");
    }
    printf("
    %d",value);
    return 0;
    }
    output
    Not same
    -1

  • @codeanalysis7085
    @codeanalysis7085 3 ปีที่แล้ว +3

    ma'am i had some doubt on string comparison. but after saw this video , i easily understand this topic. thank you ma'am.

  • @yashhokte1020
    @yashhokte1020 3 ปีที่แล้ว +17

    20:28 No if we put && operator then it will never give correct output as the function of && operator is that if both the Condition is satisfied then only it will enter to its block but if in the second string if we found the null character in 2nd block only then it will not execute that block n so we can't use && operator :)

    • @abhay4778
      @abhay4778 4 วันที่ผ่านมา +1

      you are wrong , it will work.

  • @PranathiBendalam
    @PranathiBendalam 4 หลายเดือนก่อน +2

    11:35 negative value ,since ascii value of ''i'' is greater than that of ''e''

  • @pratikmazumder544
    @pratikmazumder544 3 ปีที่แล้ว +1

    I am not student of computer science... But i watch your teaching videos.... Mathematics ka student hu... C progam k liye dekta hu

  • @Mohammadhaider-wd8wp
    @Mohammadhaider-wd8wp 6 หลายเดือนก่อน

    Thanks a lot mam you have cleared my doubts regarding this string program.

  • @xEp1c
    @xEp1c 3 หลายเดือนก่อน

    good lecture, very informative

  • @vijayroy3173
    @vijayroy3173 3 ปีที่แล้ว +3

    Madam you’re rocking in internet

  • @aftabhossain3839
    @aftabhossain3839 3 ปีที่แล้ว +4

    Thank you mam ...I am your first viewer

  • @adetolasanni007
    @adetolasanni007 2 ปีที่แล้ว +3

    I love your lesson. It is so helpful. I am subscribed to your channel now. Thank you

  • @madhavisinha6350
    @madhavisinha6350 3 ปีที่แล้ว +4

    You are best mam😘😘😘😘

  • @bloggermania
    @bloggermania หลายเดือนก่อน +2

    11:43 it will return a negative value cuz i has greater ASCII value compare to e

  • @jeanrioux8750
    @jeanrioux8750 2 ปีที่แล้ว +1

    11:40 it will return a negative value. ASCII value of 'e' is smaller than ASCII value of 'i'.

  • @subikshajegadish3525
    @subikshajegadish3525 3 ปีที่แล้ว +4

    maam i loveeee your teaching so much pls pls plssssss do DAA and OS after completeing C

  • @limitess9539
    @limitess9539 2 ปีที่แล้ว +2

    I think it gives 1 if the first non-matching letter in string is higher in first string, and -1 if the first non matching letter is smaller (obv in ASCII value)

  • @nandachowdary7686
    @nandachowdary7686 3 ปีที่แล้ว +6

    1st view and 1st like, mam, good teaching

  • @Learnandmotivation83
    @Learnandmotivation83 3 ปีที่แล้ว +5

    Mam aaap bhot achha pdhati ho

  • @dudduramasujith3120
    @dudduramasujith3120 2 ปีที่แล้ว +1

    You are to intelligent and very helpful to us

  • @brightsideoflife5148
    @brightsideoflife5148 หลายเดือนก่อน +1

    We will get the -4 as the difference of "Hello" and "Hi".

  • @anju7334
    @anju7334 3 ปีที่แล้ว +12

    You cannot use && operator .
    You can examine it by taking
    string 1 = welcome
    String 2 = we.
    👍

  • @cryptoumesh
    @cryptoumesh ปีที่แล้ว

    14:14 yes maam samjh rahe hai 🤓

  • @KiranKumar-db3rs
    @KiranKumar-db3rs ปีที่แล้ว

    I am in love with your awesome explanation

  • @khushiagarwal7913
    @khushiagarwal7913 2 ปีที่แล้ว +3

    Using && He and Hello will return same string value bcoz after 2 it will not run and flag cannot have the value of 1 since at last same value

  • @sujitmer2331
    @sujitmer2331 16 วันที่ผ่านมา

    Thanks.. 😊

  • @i23i99
    @i23i99 4 หลายเดือนก่อน +1

    12:00 for without strcmp

  • @anjanisivarambonam9895
    @anjanisivarambonam9895 3 ปีที่แล้ว +27

    madam please start python playlist from basic to advanced🤗🤗🤗

  • @ananthnatrajan9861
    @ananthnatrajan9861 6 หลายเดือนก่อน

    Hi Mam, i like your videos , and your way of teaching is so good. Regarding this program i'm using code blocks and Dev C++ IDE. for learning c. if i enter a String1 ANANTH and String2 Ananth, i'm getting the both the strings are equal.

  • @manly_meals
    @manly_meals ปีที่แล้ว

    char s1[]="Hello";
    char s2[]="Hi";
    it will give negative value (-4) because i comes after e , so i have greater sky value than e

  • @AditiRai-vo5sd
    @AditiRai-vo5sd 7 หลายเดือนก่อน

    Thank you so much mam❤️

  • @RahulSharma-ke7wg
    @RahulSharma-ke7wg 3 ปีที่แล้ว +2

    Thnx For this mam🙂

  • @durgabhavani-e4l
    @durgabhavani-e4l หลายเดือนก่อน

    Thank you very much mam

  • @gitanshagarwal7597
    @gitanshagarwal7597 2 ปีที่แล้ว +7

    On comparing string("Hello") and string("Hi") using strcmp() ,it will return negative value.

  • @isoopal9357
    @isoopal9357 3 ปีที่แล้ว +10

    Ma'am please start python series basic to advance.

    • @adithistar2189
      @adithistar2189 3 ปีที่แล้ว

      Yes ma'am please 🙏

    • @adithistar2189
      @adithistar2189 3 ปีที่แล้ว

      And ur explanation is superb and interesting . I just want to say thank u very much 👍

  • @vickypatil5829
    @vickypatil5829 2 ปีที่แล้ว +2

    Mam what it will give +ve or -ve when we give input as strl and strm

  • @vikings.777
    @vikings.777 ปีที่แล้ว +1

    16:11 if there is a chance of shot circuit ????

  • @nawing2511
    @nawing2511 3 ปีที่แล้ว +7

    2d array string with logical memory representation video mam !!

  • @yuvraj__technical9400
    @yuvraj__technical9400 3 ปีที่แล้ว +2

    Conceptual study thanks maam

  • @RiteshSharma145
    @RiteshSharma145 3 ปีที่แล้ว +3

    Ma'am, you missed strncmp concept.
    Plz make a brief video on it.

  • @vinaypratap620
    @vinaypratap620 3 ปีที่แล้ว +2

    Samjh rahe ho 😂😂😂👏👏

  • @RashiChoubey-p6e
    @RashiChoubey-p6e หลายเดือนก่อน

    Mam please explain many types of logic of programs

  • @sasanksasank1167
    @sasanksasank1167 3 ปีที่แล้ว +1

    Cp ki namaskaram 🙏🙏🙏🙏

  • @surajnegi1608
    @surajnegi1608 3 ปีที่แล้ว +9

    Mam plz add some hindi words in between please please please i regularly watch ur vedio but sometimes english makes problem to understand❤❤❤❤

  • @harygaming.8805
    @harygaming.8805 3 ปีที่แล้ว +5

    Mam is it necessary to take flag variable?
    Can we directly print ("not same"
    ); and the break;? Please reply I m get confused.

  • @aadhil9270
    @aadhil9270 ปีที่แล้ว +3

    //comparing two strings
    #include
    #include
    Void main()
    {
    char s1[]="hello";
    char s2[]="bye";
    int result=strcmp(s1,s2);
    if(result==0)
    printf("strings are equal");
    else
    printf("strings are not equal");
    }
    Output:
    strings are not equal

  • @Jyotiii007
    @Jyotiii007 2 ปีที่แล้ว +1

    I'm getting error of "expected declaration or statement at the end of input"

  • @amitkumarsingh5032
    @amitkumarsingh5032 3 ปีที่แล้ว +3

    First viewer 😊

  • @mahig2934
    @mahig2934 ปีที่แล้ว

    ma'am actually here you said that without using string.h header file you have done but some of the compilers asking string.h header file like gdb online compiler

  • @elavarasan_r154
    @elavarasan_r154 3 ปีที่แล้ว +1

    At 11:37
    It gives negative value mam

  • @universedinesh7179
    @universedinesh7179 หลายเดือนก่อน +1

    it shows the same while applying && operator.

  • @taniyanegi7211
    @taniyanegi7211 3 ปีที่แล้ว +2

    Draw a flowchart to find the fibonacci series till term

  • @souviknandi5792
    @souviknandi5792 3 ปีที่แล้ว +1

    guys ..in 5:58 time ..mam use a word something like ESCAPE or ESCAY...can you plz tell me what mam said..what is the meaning of that word?? I can't understand the word prpperly...so I can't find it's meaning in dictionary or GOOGLE.. plz help me!!!

    • @aashishomre1624
      @aashishomre1624 3 ปีที่แล้ว +2

      It is ASCII VALUE

    • @souviknandi5792
      @souviknandi5792 3 ปีที่แล้ว

      @@aashishomre1624 thank you sir...got it later in string part....thank you

  • @mdhannan5842
    @mdhannan5842 22 วันที่ผ่านมา

    ❤❤❤

  • @18fatima15
    @18fatima15 9 หลายเดือนก่อน

    11:36 negative value will be returned

  • @debojitacharjee
    @debojitacharjee 2 ปีที่แล้ว +2

    *WHERE DO WE USE IT?* - you have shown how to compare strings using for loop but you did show with a program where we need to use the strcmp() and what's it's application in software development.

  • @nitinsingh10ths.s.24
    @nitinsingh10ths.s.24 หลายเดือนก่อน

    maam if i am using space at last of string 1 but not in string2 then it is showing not same is their any chance that we can check only the character not space

  • @investmenttek8323
    @investmenttek8323 2 ปีที่แล้ว +1

    maam is it nessessary to learn without strcmp() function??

  • @khushiagarwal7913
    @khushiagarwal7913 2 ปีที่แล้ว +3

    Ma'am isma && operator hona chahiye kyuki when i=2 S2 will end no need to check S1 after this

    • @apputadhiyal9451
      @apputadhiyal9451 2 ปีที่แล้ว

      Mujhe bhi yahi doubt aa rha tha but 25:31 p dekho ki agar flag ki value 1 ho tab not same kahega aur flag ki value 1 krne k liye loop k andar jana padega.

  • @ashutoshpandey6510
    @ashutoshpandey6510 3 ปีที่แล้ว +2

    Hllo mam I new to your channel
    Can you please tell mee how to prepare for gate CSE branch
    What sources and book we have to do
    And how did you prepare
    As I want to to start
    And I am in 2nd sem of
    CSE

  • @tirthtanna7771
    @tirthtanna7771 3 ปีที่แล้ว

    by using logical and operater it will check both the conditions and as we can see that both the conditions are true so it will go further and if anyone condition is false then the program will be ended from the loop.

    • @ParamitaDey-bi1mg
      @ParamitaDey-bi1mg 3 ปีที่แล้ว

      I cannot understand why if we use and operator this program will not give desired output.. pls can you tell me..

    • @tirthtanna7771
      @tirthtanna7771 3 ปีที่แล้ว

      @@ParamitaDey-bi1mg Because to apply and operater both the conditions should be true then and then the program will be further executed

    • @ParamitaDey-bi1mg
      @ParamitaDey-bi1mg 3 ปีที่แล้ว

      @@tirthtanna7771 See my question is if we use or operator then if one condition is true then it will go inside if loop . So if we take He instead of Hi in second string then second string will have string index 2(including null character )and first string index will have 5(including null character) so here for loop will go on till i=5 although there is no need to check up to 5 because at i=2 only we get null character in string 2. But as we are using or operator so if one condition is true (means S1[2]!='\0') then only it will go to if loop but it is not checking whether S2[2] is null character or not
      So is not and operator better than or oparetor?
      I don't know whether I can clear my doubt to you or not..
      If you don't understand my question then pls say (" no I did not understand the question") or else I will wait for your reply

    • @queennath1895
      @queennath1895 3 ปีที่แล้ว

      @@ParamitaDey-bi1mg I have the same doubt too

    • @ParamitaDey-bi1mg
      @ParamitaDey-bi1mg 3 ปีที่แล้ว

      @@queennath1895 Did you got the ans?

  • @udsgyaan8464
    @udsgyaan8464 7 หลายเดือนก่อน

    Maam i love you ❤

  • @gopalgopi930
    @gopalgopi930 3 ปีที่แล้ว +2

    Mam in this logic if the strings are : "hello" and " he" the code will return that the strings are same which is not true

    • @bireswarsaha4881
      @bireswarsaha4881 2 ปีที่แล้ว

      1.you should put '\0' instead of "\0" (or) 2.use || instead of &&

    • @gopalgopi930
      @gopalgopi930 2 ปีที่แล้ว

      @@bireswarsaha4881 that's what I meant.

    • @dhineshkumars1991
      @dhineshkumars1991 2 ปีที่แล้ว

      First thing in strcmp function is ,,if length of both string is not same we can very well say ,,string is not identical in our own function case

  • @ezaf001
    @ezaf001 2 ปีที่แล้ว

    Mam just had a doubt- in if loop when flag turn to 1 u used break, will that break the if loop only ? and not the for loop and anyways once the flag is up output will be same, i am bit confused, maybe what i can saying doesn't make any sense, idk
    maybe their should be a condition outside the if loop that - if(flag==0) { break; }.

  • @soumyaprusti
    @soumyaprusti 2 ปีที่แล้ว

    11:41
    -ve

  • @kishorea8872
    @kishorea8872 2 ปีที่แล้ว

    put more videos on string like , reverse the word ,remove given char,replace given char

  • @ananthnatrajan9861
    @ananthnatrajan9861 6 หลายเดือนก่อน

    Sorry mam i made a mistake. Now i'm getting correct output

  • @RTBOSS
    @RTBOSS 3 ปีที่แล้ว

    Thank you ma'am

  • @aparnamane4899
    @aparnamane4899 2 ปีที่แล้ว

    if we use && opr in loop then it not give correct o/p , if both cond is true then only it enter into loop, so better use or opr in for loop.

  • @Learnandmotivation83
    @Learnandmotivation83 3 ปีที่แล้ว +5

    Mam ye cource compete hone ke bad data structure ke program ki list bna dena

  • @archanakumarimeena3058
    @archanakumarimeena3058 2 ปีที่แล้ว +1

    Can we compare more than two strings also , how to do that?

  • @shashank_kishore_
    @shashank_kishore_ 3 หลายเดือนก่อน

    ❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤

  • @prathapreddyjanumpally461
    @prathapreddyjanumpally461 3 ปีที่แล้ว +2

    Waiting for java lecturers

  • @marianesaliba2594
    @marianesaliba2594 2 ปีที่แล้ว

    Thank youuu

  • @Ddot-cd1in
    @Ddot-cd1in 3 ปีที่แล้ว

    11.39 it will return a nagative value

  • @ankushsarkar685
    @ankushsarkar685 7 หลายเดือนก่อน

    Since i is greater than e so, it will return negative value

  • @kanchanupadhye3648
    @kanchanupadhye3648 ปีที่แล้ว

    is it necessary to write break for for loop

  • @vinuthadc6505
    @vinuthadc6505 2 ปีที่แล้ว +1

    if you enter string 1 as" jenny kh" and string 2 as "jenny khatri", out put says "same".

    • @goplay5936
      @goplay5936 ปีที่แล้ว

      Same problem...this code has problem as when space is encountered flag is 0 so it is saying same

  • @RiteshSharma145
    @RiteshSharma145 3 ปีที่แล้ว

    @11:35 -ve would be the answer

  • @missankitabose1783
    @missankitabose1783 ปีที่แล้ว

    Can you explain the code of permutations of string

  • @amritpattnaik1540
    @amritpattnaik1540 2 ปีที่แล้ว +1

    Mam, is this method of comparing 2 strings correct?
    char S1[30], S2[30];
    int i, j, l1, l2, count = 0;
    printf("Enter 1st string: ");
    gets(S1);
    printf("Enter 2nd string: ");
    gets(S2);
    l1 = strlen(S1);
    l2 = strlen(S2);
    if(l1 != l2)
    {
    printf("The entered strings are unequal.");
    return 0;
    }
    else
    {
    for(i=j=0; i

    • @tejassharma3212
      @tejassharma3212 2 ปีที่แล้ว

      👍

    • @tejassharma3212
      @tejassharma3212 2 ปีที่แล้ว

      First else ka close bracket second else ke statement ke baad close karein to sahi ho jayega

    • @amritpattnaik1540
      @amritpattnaik1540 2 ปีที่แล้ว

      Wo mai header file mention nhi kiya hu yha pe to last wala curly brace uske liye hai 😅

  • @manikantarajudhavala3543
    @manikantarajudhavala3543 3 ปีที่แล้ว +6

    /* prgram for str cmp*/
    #include
    #include
    #include
    main()
    {
    Char s[20], h[20];
    Closer() ;
    Printf ("
    enter a string 1") ;
    gets(s) ;
    Printf ("
    enter a string 2") ;
    gets(h) ;
    If(strcmp(s, h) ==0)
    Puts("
    two strings are identical") ;
    else
    Puts("
    two strings are not identical“)
    }
    Out put:-
    Enter a string
    MANIKANTA
    Enter a string
    MANIKANTA
    two strings are identical
    MAAM CAN I WRITE THIS TYPE

    • @pariveshsolasa4878
      @pariveshsolasa4878 2 ปีที่แล้ว +3

      right but in one statement u missed semi colon

  • @dammarrawat784
    @dammarrawat784 3 ปีที่แล้ว

    Medam how to contract you . Please ineed your help

  • @arvindchandrakar
    @arvindchandrakar 2 ปีที่แล้ว

    Mam strchr( ) ka video nai h kya ?

  • @sameeralikhan5133
    @sameeralikhan5133 2 ปีที่แล้ว

    what will happen if first character of both char arrays are same??

  • @manikantarajudhavala3543
    @manikantarajudhavala3543 3 ปีที่แล้ว +2

    Maam please tell about arry, one dimentional array, two dimentionalarry multi dimentional erray and( arry string)

  • @isaacl.quelemine8775
    @isaacl.quelemine8775 ปีที่แล้ว

    The condition will still be satisfy

  • @abdulrahimjalloh363
    @abdulrahimjalloh363 ปีที่แล้ว

    Hello
    Hi
    It will return -ve. Because i ascii is greater than e ascii

  • @Smoke-mk7yh
    @Smoke-mk7yh 2 ปีที่แล้ว

    Why mam is not taking the sije of string

  • @pradeeprao2473
    @pradeeprao2473 3 ปีที่แล้ว +2

    Your too g❤️❤️d

  • @enviesyy5294
    @enviesyy5294 3 ปีที่แล้ว

    11.39 it will gives negative no.

  • @aryanpandey2504
    @aryanpandey2504 8 หลายเดือนก่อน

    ma'am i love you

  • @RajeshKumarMinaBEE
    @RajeshKumarMinaBEE 3 ปีที่แล้ว

    Mam how many lectures in this course

  • @gammer978
    @gammer978 3 ปีที่แล้ว

    What is the use of flag