C Aptitude Questions and answers with explanation

C Aptitude 30C program is one of most popular programming language which is used for core level of coding across the board. C program is used for operating systems, embedded systems, system engineering, word processors,hard ware drivers, etc. In this site, we have discussed various type of C programs till date and from now on, …

Write a C program to reverse a string using pointers.

C Strings:Write a C program to reverse a string using pointers.In this program, we reverse the given string by using the pointers. Here we use the two pointers to reverse the string, strptr holds the address of given string and in loop revptr holds the address of the reversed string. Read more about C Programming …

K&R C Programs Exercise 7-4

Exercise 7-4. Write a private version of scanf analogous to the private printf described in this section. Like minprintf, minscanf parses a format string and uses va_list to accept a variable number of pointer arguments. It reads from stdin and dispatches to the appropriate conversion — using scanf itself with a constructed sub-format string, so …

K&R C Programs Exercise 5-20

Exercise 5-20. Expand dcl to handle declarations with function argument types, qualifiers like const, and so on. The basic dcl treats () as “function returning” but ignores argument types. This exercise adds: parameter lists inside (), type qualifiers (const, volatile), storage classes (static, extern), and the void type. The approach: when ( is encountered and …

K&R C Programs Exercise 5-17

Exercise 5-17. Add a field-handling capability, so sorting may be done on fields within lines, each field sorted according to an independent set of options. (The index for this book was sorted with -df for the index category and -n for the page numbers.) Fields are whitespace-delimited columns. The syntax -k<field>[flags] selects a 1-based field …

K&R C Programs Exercise 5-15

Exercise 5-15. Add the option -f to fold upper and lower case together, so that case distinctions are not made during sorting; for example, a and A compare equal. Add a fold flag. When set, the comparison function converts both characters to lowercase before comparing. The key: don’t modify the strings themselves — do the …