Ad Code

Responsive Advertisement

First Occurrence of Starting Index(Case sensitive)

 

First Occurrence of Starting Index Using C program

First Occurrence of Starting Index(Case sensitive):

C Program:

Output 1:

First Occurrence of Starting Index(Case sensitive)

Output 2:

First Occurrence of Starting Index(Case sensitive)output

From the above program,

ü String 1 is stored in a and string 2 stored in b.


ü first character of 'a' is compared with the first character of 'b', if it matches then remaining characters are checked with 'b' using the for loop within if.

ü To indicate that the remaining characters of 'a' matches, 'c' is assigned to 1, when the mismatch occurs 'c' will be assigned to '0' then the control comes out of the loop. Till the loop comes out 'i' will remain same.


ü If the 'c' value remains 1 throughout the loop then the 'i' value is increamented by 1 and printed since 'i' is the index value of the character, to know the position of the starting character 'i' is added by 1.

  Note: First Occurrence of Starting Index(Case Insensitive).

Post a Comment

0 Comments

Close Menu