Checking for special symbol in a String in C Programming

Selection sort
Selection sort
5
(2)

Code

#include<stdio.h>
#include<string.h>
int main()
{
  int i,d,counter=0;
  char arr[100];
  printf("enter a String \n");
  scanf("%[^\n]", arr); //taking multiple input by scanf by skipping the  \n
  //scanf("%s",arr);
  //special character ascii range (32–47 / 58–64 / 91–96 / 123–126)
  for(i=0;arr[i]!='\0';i++)
  {
    d=arr[i];

    //printf("%c%d",arr[i],d);
    if((d>=32 && d<=47) || (d>=58 && d<=64) || (d>=91 && d<=96) || (d>=123 && d<=126))
    {
      counter++;
      printf("operator found %d time\n",counter);
      printf("special character is %c\n",d);
    }
    
    

  }
  
  //printf("%d",i);
  return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
  int i,d,counter=0;
  char arr[100];
  printf("enter a String \n");
  scanf("%[^\n]", arr); //taking multiple input by scanf by skipping the  \n
  //scanf("%s",arr);
  //special character ascii range (32–47 / 58–64 / 91–96 / 123–126)
  for(i=0;arr[i]!='\0';i++)
  {
    d=arr[i];

    //printf("%c%d",arr[i],d);
    if((d>=32 && d<=47) || (d>=58 && d<=64) || (d>=91 && d<=96) || (d>=123 && d<=126))
    {
      counter++;
      printf("operator found %d time\n",counter);
      printf("special character is %c\n",d);
    }
    
    

  }
  
  //printf("%d",i);
  return 0;
}


Output

Checking for special symbol in a String in C Programming

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 2

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *