Checking for special symbol in a String in C Programming

Selection sort

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
📢 Share this tutorial:
👨‍💻

Nagendra Rana

Software Development Engineer 2 (SDE-2) @ Digilytics AI & Founder of WhatInfoTech

Architecting scalable enterprise Angular applications, Spring Boot 3 microservices, Python / FastAPI, PostgreSQL, and AI document extraction solutions.

← Previous Article

How to perform basic SQL operation Using Hibernate in NetBeans

Next Article →

Hackthebox armageddon writeup

📖 Recommended Technical Tutorials

Leave a Reply

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

Support My Work