A word is a consecutive non-whitespace character set. The C program here will find out the longest word in a given string. If multiple words are present with the same length of the longest one, it will print the first one. This program takes a string as input. The first ‘for‘ loop traverses all the … Continue reading “C Program to Find the Longest Word in a String”
C Program to Count Occurrences of Each Element in an Array
Here we’ll see how to write C program to count occurrences of each element in an array. The C program will check how many times a particular integer occurs in the array. This program first takes the array size and the array elements as input. It maintains another array of same size to keep the … Continue reading “C Program to Count Occurrences of Each Element in an Array”
Python | Capture Ctr+C (SIGINT)
Some programs are meant to run for indefinite amount of time. They don’t stop by themselves. Operators generally stop then for maintenance. Most common way to stop these types of programs is by pressing Ctr+C if the program is running in foreground or by sending SIGINT signal. Here is a simple Python program that does … Continue reading “Python | Capture Ctr+C (SIGINT)”
Python | Periodic Task
Doing a periodic task is a basic programming requirement. We need it in time of implementing watchdogs, checking health of some system, sending status periodically, updating database, doing periodic backup etc. Using Loops When it comes to do something periodically, the first that comes to our mind is the ‘loop‘. First we’ll see how we … Continue reading “Python | Periodic Task”
Python | Check Whether a String is Palindrome
Palindrome string is a string that reads same from both directions – forward and backward. For example, the string, ‘ROTOR‘, is a palindrome because it reads same from both forward and backward directions. Whereas ‘MOTOR’ is not a palindrome because it does not read same from both directions. Check Palindrome by Reversing the String For … Continue reading “Python | Check Whether a String is Palindrome”