Tag Archives: C program

Number of trailing zeros in factorial of an integer

An integer n is given, the task is to find the number of trailing zeros in n! .

Posted in Coding Discussions, Computer Science, Others | Tagged , , , | Leave a comment

Find Sum (i … j) in a list

The problem is to sum the ith to jth element of a given list. The easiest solution runs in time, which starts are the ith index and adds up the numbers in the list until it reaches the jth index. … Continue reading

Posted in Coding Discussions, Computer Science | Tagged , , | Leave a comment

Find a String in an Alphabet Grid

Everybody of us has definitely played the word search game in which a grid of characters are given, and a list of words are given which are to be found in the grid horizontally, vertically or diagonally. In this post … Continue reading

Posted in Coding Discussions, Computer Science | Tagged , | Leave a comment

Towers of Hanoi Iterative process: simulating recursion

The last post Recursive Solution to Towers of Hanoi described the well-known recursive definition and implementation of the Towers of Hanoi problem. This post is an extension presenting the same problem iteratively by simulating the recursion stack. This implementation will … Continue reading

Posted in Coding Discussions, Computer Science | Tagged , | Leave a comment

Recursive Solution to Towers of Hanoi

Towers of Hanoi is a mathematical game or a puzzle in which there are three pegs, and some disks (originally 8) of different radius placed on top of one another such that no larger disk is placed on a smaller … Continue reading

Posted in Coding Discussions, Computer Science | Tagged , | 3 Comments

Using scanf safely

Beginners find that the scanf function behaves strangely when you input a character when scanf expects an integer or float. When used inside a loop (taking options), it loops infinitely. Here is a short post which explains what it happens, … Continue reading

Posted in C Language, Computer Science | Tagged , | Leave a comment

Accessing private data members directly outside from its class in C++

Private members in C++ cannot be accessed from outside the class directly. In this post I will tell an interesting fact, that in C++ however there are means with which you can access/modify the values of the private members of … Continue reading

Posted in C Language, Computer Science | Tagged , , | 1 Comment

Input Strings with Blankspaces

In CLI programs getting input from the standard input is very important. Often we need to input strings from the user. Strings are delimited by newline, blankspace character and other characters as per the user interpretation. I am discussing on … Continue reading

Posted in C Language, Computer Science | Tagged , | 1 Comment

Allocating multidimentional array at runtime in C

Arrays in C language are static in nature, and cannot be resized at runtime. The effect of runtime allocation of an array could be achieved by hierarchically allocating blocks of memory at runtime. Below we discuss the mechanism to allocate … Continue reading

Posted in Coding Discussions, Computer Science, C Language | Tagged , | 2 Comments

C Language Constructors and Destructors with GCC

Constructors and Destructors are special functions. These are one of the features provided by an Object Oriented Programming language. Constructors and Destructors are defined inside an object class. When an object is instantiated, ie. defined of or dynamically allocated of … Continue reading

Posted in C Language, Computer Science | Tagged , , | 9 Comments