Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

CharAt() - Find the Character at the Given Position in C

  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. char s[30];
  6. int i,n,x;
  7.  
  8. printf("enter the string:");
  9. scanf("%s",s);
  10. x=strlen(s);
  11. printf("enter the position of a char to be find:");
  12. scanf("%d",&n);
  13. if(n<x)
  14. {
  15. for(i=0;s[i]!='\0';i++)
  16. {
  17. if(n==i)
  18. printf("the char at this position is:%c",s[i]);
  19. }
  20. }
  21. else
  22. printf("the char is not present");
  23. }
  24. }
  25. else
  26. printf("the char is not present");
  27.  
  28. }
  29.