Camel case in hackerRank (IN C)

problem link

/*In this problem Every word is started with a capital letter(Except the First word) and no space is given. so there is a word where a capital letter is found. So no of words is equal to no of capital letters +1(we need to include the first word which doesn't contain capital letters.*/

 #include<stdio.h>

#include<string.h>

#define max 100001 //giving the constant value for no of characters in a string,

int main()

{

    char str[max];

    int i,count=0,j;

    scanf("%s",&str);

    for(j=0;j<strlen(str);j++)

    {

    for(i=65;i<=90;i++)    // ascii value of  'A'=65 , 'Z'=90

    {

        if(str[j]==i)  

        {

            count=count+1;

        }

    }

    }

    printf("%d",count+1);

    return 0;

}


//post your doubts in comments...


Comments