Category Archives: Computer Science

All about Computers

Implement queue using stack

The puzzle is to implement basic queue operations with using only basic stack operations. That is, a stack object is given, we need construct a wrapper for the queue functions, insert, remove, which will only use the stack object as … Continue reading

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

Plot histogram in terminal

We had assignments to print “*”s in different formation in undergraduate class, which I never liked as they were pointless. Now I got a somewhat justifiable application, plot histogram in terminal. In the last post Generating random numbers from Normal … Continue reading

Posted in Coding Discussions, Computer Science | Tagged , , , , | 1 Comment

Generating random numbers from Normal distribution in C

I needed to write a random number generator in C which will generate random numbers from Normal Distribution (Gaussian Distribution). Without this component I couldn’t proceed to finish writing a C code for Heuristic Kalman Algorithm by Lyonnet and Toscano … Continue reading

Posted in Coding Discussions, Computer Science | Tagged , , , , | 1 Comment

C LANGUAGE UERS! Y U NO SEE STANDARDS!

I had to make this. There are people who give a damn to the standards and follow the stone age Turbo C 3.1 compiler, run programs compiled by it. In the cases for compiler dependent and undefined behaviours, they try … Continue reading

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

C Q&A #5: A question about assignment operation and evaluation

Here is another C code snippet question. Consider the following piece of code, and spot if there is a problem in it or not.

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

Dynamically allocating 2d array with adjacent rows in memory

In a previous post “Allocating multidimentional array at runtime in C” I have explained a technique to allocate multidimensional arrays on runtime. While playing around with OpenMPI, I came to know that while sending/receiving a buffer, it requires the elements … Continue reading

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

Journey of a simple recursive code

Some one asked the following question in StackOverflow Implement a function with prototype char *repeat(char *s, int n) so that it creates and returns a string which consists of n repetitions of the input string s. For example: if the … Continue reading

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

Implement stack using a queue

The puzzle is to implement basic stack operations with using only basic queue operations. That is, a queue object is given, we need construct a wrapper for the stack functions, push, pop, which will only use the queue object as … Continue reading

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

C Q&A #4: Calling main recursively

What do you think about the following C Code ? What will be the output.

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

Detect Endianness of a System

In a previous post “Little and Big Endian conversion” i have briefly discussed about the Big-Endian and the Little-Endian representations. It is the ordering of the bytes (elementary addressable elements) within the representation of a larger basic data type. These … Continue reading

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