C Program to Print the Current File Name and Line Number

Real life programs are generally very big distributed across many files with hundreds of lines. Sometimes we need to print the current file name and the line number. Like, it greatly helps the developers if we print the file name and line number with debug logs. To do that, you can embed hard coded the … Continue reading “C Program to Print the Current File Name and Line Number”

C “Hello, World” Program

The iconic “Hello, World” program simply prints the message “Hello, World” on the screen. Brian Kernighan used it as a very simple C example program in late 70’s. It became popular since then. Many use this as a first program to learn a new programming language. It is also used check the readiness of a … Continue reading “C “Hello, World” Program”

C Program to Find the Shortest Word in a String

A word is a consecutive non-whitespace character set. The C program here will find out the shortest word in a given string. If multiple words are present with the same length of the shortest 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 Shortest Word in a String”

C Program to Find the Longest Word in a String

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”

0
0
0
2
7
0