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.
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.
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).
Write an alternate version of squeeze(s1, s2) that deletes each charecter in s1 that matches any charecter in the string s2.
\(\dfrac{5 + 4 + (2 - (3 - (6 + \dfrac{4}{3})))}{3(6 - 2) (2-7)}\)
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.
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
.
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.
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.
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;
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.
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.
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.