Jun 23, 2021

K & R : Exercise 2.6 - setbits

K & R : Exercise 2.6 - setbits

Problem

Write a function setbits(x, p, n, y) that returns x with n bits that begin at position p set to the right most n bits of y, leaving the other bits unchanged.

Jun 22, 2021

K & R : Exercise 2.5 - alternate strpbrk

K & R : Exercise 2.5 - alternate strpbrk

Problem

Write the function any(s1, s2) which returns the first location in the string s1, where any charecter from s2 occurs or -1 if s1 contains no charecters from s2. (The standard library function strpbrk does the same job but returns a pointer to the location).

Jun 21, 2021

K & R : Exercise 2.4 - squeeze string

K & R : Exercise 2.4 - squeeze string

Problem

Write an alternate version of squeeze(s1, s2) that deletes each charecter in s1 that matches any charecter in the string s2.

Aug 16, 2017

SICP# E1.2: Translate formula to prefix notation

SICP# E1.2: Translate formula to prefix notation

Translate the following expression into prefix form

\(\dfrac{5 + 4 + (2 - (3 - (6 + \dfrac{4}{3})))}{3(6 - 2) (2-7)}\)

Aug 15, 2017

SICP# E1.1: Evaluate scheme expression

SICP# E1.1: Evalute scheme expression

Below is a sequence of expressions. What is the result printed by the interpretter in response to each expression ? Assume that sequence is to be evaluated in the order in which it is presented.

Nov 27, 2016

Blog: My life changing YouTube video (FIGHTMEDIOCRITY TOP 9 BOOKS)

Blog #3: My life changing YouTube video (FIGHTMEDIOCRITY TOP 9 BOOKS)
Around 7 months ago I stumbled across a YouTube video by a channel FightMediocrity. I had subscribed to that channel long back, but some how had missed this particular video. You can see the whole video below

It is 17:52 minute long video which lists Fightmediocrity's top 9 books. I highly recommend you to watch the video and then continue reading.

Nov 26, 2016

Blog: Vada

Blog #2: Vada
Saturday and Sunday being the weekends, my wife makes some wonderful breakfast. Weekdays i generally have my breakfast in office cafeteria. Yesterday being a Friday, I made general enquiry to my wife in evening what is special tomorrow for breakfast. She declared it is Vada (It is south indian dish). My wife's preparation of Vada and Sambar (side dish) is the best. If you are interested in making Vada, you can see this youtube video Medu Vada - By VahChef @ VahRehVah.com.

C Programming #91: fileio - fprintf, fscanf

C Programming #91: fileio - fprintf, fscanf

Similarly how there was formatted print function for stdio, there are function that could be used with file. We could apply all the formatting tricks that was used for printf and scanf.

Nov 25, 2016

Blog: Getting started, Why K&R is the best book on C programming?

Blog #1: Getting started, Why K&R is the best book on C programming?
On November 25th 2016 @ 8:20 I have decided that - "I would write a blog daily". My idea is to write on something interesting and fun. It will be on wide range of things including but not restricted to books, technical topic, personal, philosophical, god, daily routine or YouTube videos… My idea is Writing daily would lead to creative life and I can hone my writing skills to too. Making it public is to take criticism and to improve.

K & R : Exercise 2.3 - htoi - hex to integer

K & R : Exercise 2.3 - htoi - hex to integer

Problem

Write the function htoi(s) which converts a string of hexadecimal digits (including an optional 0x, 0X) into its equivalent integer value. Allowable digits are 0..9, a through f, A through F.

Nov 15, 2016

C Programming #90: fileio - fopen, fclose, fgetc, fputc, fgets, fputs

C Programming #90: fileio - fopen, fclose, fgetc, fputc, fgets, fputs

This article go through several API related file operation. Linux/Unix core philosophy is that everything is a file. Hence file operations becomes core of any application/system programming. Hence for a person who claims to be good at 'C' need to know the file operation really well. In this series of article it introduces all the API with example it it never tries to exhaustive, for which you can always refer man pages.

Nov 14, 2016

K & R : Exercise 2.2 - loop equivalent

K & R : Exercise 2.2 - loop equivalent

Problem

Write a loop equivalent to the for loop below without using && or ||.

for(i=0; i < lim -1 && (c=getchar()) != '\n' && c != EOF; ++i)
  s[i] = c;

Sep 8, 2016

C Programming #89: printf - %n specifier

C Programming #89: printf - %n specifier

This article explains format specifier %n which can be used in printf. Already other format specifiers are covered C Programming #87: stdio - printf, scanf and C Programming #88: stdio - insane formating in printf.

Sep 7, 2016

K & R : Exercise 2.1 - Range of char, short, int and long

K & R : Exercise 2.1 - Range of char, short, int and long

Problem

Write a Program to determine the ranges of char, short, int and long variables. Both signed and unsigned by printing appropriate values from standard header and by direct computation. Harder if you compute them determine the ranges of various floating point types.

Sep 6, 2016

C Programming #88: stdio - insane formatting in printf

C Programming #88: stdio - insane formatting in printf

We have covered simple format specifier for printf and scanf here [C Programming #87: stdio - printf, scanf]. This article tries to give incrementally with example most complex and insane formatting that could be achieved. I don't expect you to remember all of it. My idea to here is to show how beautiful and complex the construct are.