Advertisement
AnnJ

index of

Nov 18th, 2016
1,231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4.  
  5. char L[5]="abdba";
  6. int indexof(char x)
  7. {
  8. int i;
  9. for(i=0;i<5;i++)
  10. {
  11. if(x==L[i]){
  12.  
  13. return i;
  14. }
  15.  
  16.  
  17. }
  18.  
  19. return -1;
  20.  
  21. }
  22. int main()
  23. {
  24. printf("%d\n",indexof('d'));
  25. printf("%d\n",indexof('a'));
  26. printf("%d\n",indexof('z'));
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement