To find the non repeating characters in a given string, we will first iterate the each characters of string and records the count. To records the counts we will have one more integer array which will store the frequency of each characters. At last will print only those character that occurs only one time.
How our program will behave?
- Our program will take one string as an input.
- We will have one extra integer array to keep the frequency of all characters of string.
- Now we will print only those characters that occurs only once in string.
C Program to print all non repeating characters in string
#include <stdio.h> int main() { //Initializing variables. char str[100]; int i; int freq[256] = {0}; printf("C Program to find all non repeating character\n"); printf("Enter the string: "); scanf("%[^\n]",str); //Here we are calculating the frequency of all characters for(i = 0; str[i] != '\0'; i++) { freq[str[i]]++; } printf("Character which has no repetitions are \n"); for(i = 0; i < 256; i++) { //Here is the check to print only character //which has came only once if(freq[i] == 1) { printf("%c ", i); } } return 0; }
Output
[wpusb]
Also Prepare Below Important Question
- Sum of digits of Given Number in Java
- Hibernate Interview Questions for 2+ years of experience
- 68 Most Important Microservices Interview Questions
- 60 Most Important Git Interview Questions
- 50+ Mostly asked Java Interview Questions for 6 Years Exp.
- 60+ Mostly Asked Java Interview Questions for 4 Years Exp
- 60+ Mostly asked Java Interview Question for 3+ Years
- 60+ Spring Boot interview questions for 4+ years Exp.
- 60+ Mostly Asked Spring Boot Interview Questions for 3+ Yrs
- Scenario Based Java 8 Coding Interview Questions (For Experienced)
- Python Program to add two numbers without addition operator
- Mostly Asked Java Interview Questions For 2 Yrs Experience
- Find All Pairs in Array whose Sum is Equal to given number Using Java
- Java Program to find GCD of two Numbers using Recursion
- Python Program to Separate Characters in a Given String
- Python Program to add two number using Recursion
- Python Program to Find Highest Frequency Element in Array
- Python Program to Merge two Arrays
- Perform left rotation by two positions in Array Using Python
- Python Program to Delete Element at Given Index in Array
Interview Questions Categories
C Programming Interview Preparation
Core Java Programming Interview Preparation
- Core Java Programming Coding Questions
- Core Java Pattern Programming Questions
- Core Java Programming Interview Questions