fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main(void) {
  4. // your code goes here
  5. char str[100];
  6. int count=0;
  7. printf("Enter a string: ");
  8. scanf("%s", &str);
  9. for(int i=0;str[i]!='\0';i++){
  10. int alphabetpos;
  11. if(isupper(str[i])){
  12. alphabetpos=str[i]-'a'+1;
  13. }
  14. else if(islower(str[i])){
  15. alphabetpos=str[i]-'a'+1;
  16. }
  17. else{
  18. continue;
  19. }
  20. if(alphabetpos == (i+1)){
  21. count++;
  22. }
  23. }
  24. printf("Output: %d\n",count);
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
Enter a string: Output: 0