Ad Code

Responsive Advertisement

C program to find the First Occurrence of Starting Index(Case Insensitive)

 

First Occurrence of Starting Index Using C program

First Occurrence Of Starting Index Using C (Case InSensitive)


First Occurrence of Starting Index(Case Insensitive):

C Program:

Output 1:

First Occurrence of Starting Index(Case Insensitive)output

Output 2:

First Occurrence of Starting Index(Case Insensitive)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.

ü tolower() is used to convert the uppercase letters to lowercase letters for comparing.


ü 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 Sensitive).

Post a Comment

0 Comments

Close Menu