Advanced C Programming Assignments and Exercises are a set of problem statements, which will ensure you apply the concept you have learned in your classroom. By solving these assignments, you will go through a systematic problemsolving approach which includes requirement understanding, algorithm design, pseudocode creation, dry run, and final execution. As you move from simple to more complex assignments of each module it will slowly start building your selfconfidence.
Description:
In number theory, a perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors excluding the number itself (also known as its aliquot sum). Equivalently, a perfect number is a number that is half the sum of all of its positive divisors (including itself).
Example:
The first perfect number is 6, because 1, 2, and 3 are its proper positive divisors, and 1 + 2 + 3 = 6. Equivalently, the number 6 is equal to half the sum of all its positive divisors: ( 1 + 2 + 3 + 6 ) / 2 = 6. The next perfect number is 28 = 1 + 2 + 4 + 7 + 14. This is followed by the perfect numbers 496 and 8128
Prerequisites:
 Loops
 Arithmetic operators
Objective:
 To understand the concept of Ifelse constructs
 ifelse construct
Inputs:
A positive integer say ‘N’. Where N < 220
Sample Execution / Output:
Test Case 1: Positive Numbers
Test Case 2: Positive Numbers
Test Case 3: Negative Number
Test Case 4: N > 2^{20}
Description:
 In mathematics, the Fibonacci numbers or Fibonacci sequence are the numbers in the following integer sequence 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 . . . OR 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 . . .
 By definition, the first two numbers in the Fibonacci sequence are either 1 and 1, or 0 and 1, depending on the chosen starting point of the sequence, and each subsequent number is the sum of the previous two
Prerequisites:
 Loops
 Arithmetic operators
Objective:
 To understand the concept of
 ifelse construct
 Continuos looping
Inputs:
 A integer say ‘N’
Sample Execution / Output:
Test Case 1: Positive Numbers
Test Case 2: Positive Numbers
Test Case 3: Negative Number
Test Case 4: Negative Number
Description:
When the program is run, the provided string should be printed on the terminal in X formation
Prerequisites:
 Loops
 Arithmetic operators
Objective:
 To understand the concept of
 ifelse construct
 Continuos looping
Inputs:
A integer say ‘N’. Where N < 2^{5}
Sample Execution / Output:
Test Case 1:
Test Case 2:
Test Case 3:
Description:
AP
In mathematics, an arithmetic progression (AP) or arithmetic sequence is a sequence of numbers such that the difference between the consecutive terms is constant.
For instance, the sequence 5, 7, 9, 11, 13, 15 … is an arithmetic progression with common difference of 2.
GP
In mathematics, a geometric progression, also known as a geometric sequence, is a sequence of numbers where each term after the first is found by multiplying the previous one by a fixed, nonzero number called the common ratio.
For example, the sequence 2, 6, 18, 54, … is a geometric progression with common ratio 3. Similarly 10, 5, 2.5, 1.25, … is a geometric sequence with common ratio 1/2.
HP
In mathematics, a harmonic progression (or harmonic sequence) is a progression formed by taking the reciprocals of an arithmetic progression.
Prerequisites:
 Loops
 Arithmetic operators
 Data Types
Objective:
 To understand the concept of
 ifelse construct
 Continuos looping
 Type Casting
Inputs:
Positive integers say ‘A’, ‘R’ and ‘N’
where:
 A = First number
 R = Common difference(AP & HP), Common ratio(GP)
 N = number of terms
 A, R and N should be < 2^{10}
Sample Execution / Output:
Test Case 1: Positive Inputs
Test Case 2: Negative Input(s)
Test Case 3: Any one value greater than 2^{10}
Description:
Suppose, in a week let us assume first day is ‘Sunday’, then second day will be ‘Monday’ and so on. If first day is ‘Monday’ then the second day will be ‘Tuesday’ and so on.
Prerequisites:
 Loops
 Arithmetic operators
 Switch Case
Objective:
 To understand the concept of
 Switch Case
Inputs:
 Positive integer say ‘N’. Where 1 <= ‘N’ <= 365.
Option to set the first day.
Sample Execution / Output:
Description:
Print the Decimal numbers from 0 to 127 in Octal, Hexadecimal and in ASCII representation.
Display as ‘Non Printable’ for nonprintable characters
Prerequisites:
 Loops
Objective:
 To understand the concept of
 Loops and ASCII characters
Inputs:
None
Sample Execution / Output:
Test Case 1:
Description:
Print the size of basic data types – int, char, float, double, void
Print the size of the above data types while using different qualifiers – short, long, unsigned etc.
Prerequisites:
 Sizeof operators
Objective:
 To understand the concept of
 Basic C datatypes and its size
Inputs:
None
Sample Execution / Output:
Test Case 1:
Description:
 Read number n from user.
 Check the zeroth bit(on LSB end) of the number.
 if last bit is 1, number is odd.
 if last bit is zero, number is even.
 Prompt for continue option.
Prerequisites:
 If Else
 Bitwise Operators
Objective:
 To understand the concept of
 Bitwise Operators
Inputs:
Integer N
Sample Execution / Output:
Test Case 1:
Test Case 2:
Description:
 Read number n from user.
 Print the 32 bit binary representation of n and n.
 And compare both.
 Prompt for continue option.
Prerequisites:
 Bitwise Operators
Objective:
 To understand the concept of
 2’s Compliment and Bitwise Operators
Inputs:
Integer N
Sample Execution / Output:
Test Case 1:
Description:
The user entered number should identified whether its a odd or a even number. Mention its sign too.
Prerequisites:
 Loops
 Arithmetic Operators
 Nested ifelse construct
Objective:
 To understand the concept of
 Nested ifelse
Inputs:
Integer N. Where ‘N’ < 2^{20}
Sample Execution / Output:
Test Case 1:
Description:
In mathematics, the sieve of Eratosthenes, one of a number of prime number sieves, is a simple, ancient algorithm for finding all prime numbers up to any given limit. It does so by iteratively marking as composite (i.e., not prime) the multiples of each prime, starting with the multiples of 2.
The sieve of Eratosthenes is one of the most efficient ways to find all of the smaller primes. It is named after Eratosthenes of Cyrene, a Greek mathematician.
Prerequisites:
 Loops
 Arithmetic Operators
 Arrays
Objective:
 To understand the concept of
 Ifelse constructs
 Arrays
Inputs:
Integer N. Where ‘N’ < 2^{20}
Sample Execution / Output:
Test Case 1: A positive number
Test Case 2: A negative number
Test Case 3: Number greater than 2^{20}
Description:
In probability theory and statistics, a median is described as the number separating the higher half of a sample, a population, or a probability distribution, from the lower half. The median of a finite list of numbers can be found by arranging all the numbers from lowest value to highest value and picking the middle one.
Example: For getting the median of input array { 12, 11, 15, 10, 20 }, first sort the array. We get { 10, 11, 12, 15, 20 } after sorting. Median is the middle element of the sorted array which is 12.
Prerequisites:
 Loops
 Arrays
Objective:
 To understand the concept of
 Onedimensional Arrays
Inputs:
 2 Integer Array of ‘N’ elements. Where ‘N’ < 10
Requirements:
 [ ]
Sample Execution / Output:
Test Case 1: Equal sized arrays
Test Case 2: Unequal sized arrays
Test Case 3: N greater than 10
Description:
ctype library functions check whether c, which must have the value of an unsigned char or EOF, falls into a certain character class according to the current locale.
 isalnum() – checks for an alphanumeric character; it is equivalent to (isalpha(c)  isdigit(c)).
 isalpha() – checks for an alphabetic character; in the standard “C” locale, it is equivalent to (isupper(c)  islower(c)). In some locales, there may be additional characters for which isalpha() is true—letters which are neither upper case nor lower case.
 isascii() – checks whether c is a 7bit unsigned char value that fits into the ASCII character set.
 isblank() – checks for a blank character; that is, a space or a tab.
Prerequisites:
 Loops
 Functions
Objective:
 To understand the concept of
 Functions
Inputs:
 An ASCII character
Sample Execution / Output:
Test Case 1:
Test Case 2:
Description:
 get_nbits
 If num is 10 and n is 2,
10 > 0 0 0 0 1 0 1 0
Take 2 bits from LSB end of 10 (1 0) and return the corresponding decimal of that.
So get_nbits(10, 2) function should return 2
 If num is 10 and n is 2,
 replace_nbits
 Read number num from user.
 Read number n from user.
 Read number val from user
 Fetch n number of bits from LSB end of val and replace in the last n bits of num.
 Return new value of num.
If num is 10 and n is 3 and val is 12
10 > 0 0 0 0 1 0 1 0
—–
12 > 0 0 0 0 1 1 0 0
—–
The function should return 12 (1 1 0 0)  get_nbits_from_pos
 Read number num from user.
 Read number n from user.
 Read number pos from user.
 Fetch n number of bits from given position ‘pos’ (starting from LSB) of num and return the decimal value of it.
If num is 12, n is 3 and pos is 4
7 6 5 4 3 2 1 0
—————–
12 > 0 0 0 0 1 1 0 0
—————–
The function should return 3 (0 1 1).  replace_nbits_from_pos
 Read number num from user.
 Read number n from user.
 Read number pos from user.
 Read number val from user.
 Fetch n number of bits from LSB of val.
 Place those fetched bits from pos positionth bit of num and return new value of num.
If num is 12, n is 3, pos is 4 and val is 20
7 6 5 4 3 2 1 0
20 > 0 0 0 1 0 1 0 0
—————–
10 > 0 0 0 0 1 1 0 0
—————–
return value> 0 0 0 1 0 0 0 0
So function should return 16 (1 0 0 0 0).  toggle_bits_from_pos
 Read number num from user
 Read number n from user
 Read number pos from user
 Invert the n number of bits from pos positionth bit of num.
 Return the new value of num
If num is 10, n is 3, and pos is
7 6 5 4 3 2 1 0
——————
10 > 0 0 0 0 1 0 1 0
——————
return value > 0 0 1 1 0 0 1 0
So the function should return 50 (0 0 1 1 0 0 1 0)  print_bits
 Read number num from user.
 Read number n from user.
 Do error checking
> If n is greater than integer size, assign n value as sizeof integer.
d. Print n number of bits of num from LSB end.
If num is 10 and n is 12, then print last 12 bits of binary representation of 10.
The output should be > 0 0 0 0 0 0 0 0 1 0 1 0
Prerequisites:
 Functions
 Bitwise Operators
Objective:
 To understand the concept of
 Bitwise Operators
Inputs:
 An integer N, No of bits B and Position P
Sample Execution / Output:
Test Case 1:
Description:
 Read number n from user.
 Read number i from user.
 Read number a from user(0 < a < 31)
 Do error checking
 Check a is within limit or not.
 Read number b from user(a < b < 31)
 Do error checking
 Check b is within limit or not.
 Call set_nbits_from_pos function by passing i, b – a + 1, b and n as arguments.
 set_nbits_from_pos(i, b – a + 1, b, n);
 Print the new value of i.
 Prompt for continue option.

Prerequisites:
 Loops
 Bitwise Operators
 Type Modifiers
 Functions
Objective:
 To understand the concept of
 Functions
 Bitwise Operators
Inputs:
 Integers N, I, A, B
Sample Execution / Output:
Test Case 1:
Description:
 Read a number num from user.
 Read a number n from user.
 Select the option among
 Circular right shift
 Circular left shift
 Pass num and n to the corresponding functions.
 Shift num, n times (either left or right, depends on function).
 While shifting the shifted bits should get replaced at the alternate end.
 For right shifting, the shifted bits should come at left most side.
 For left shifting, the shifted bits should come at right most side.
 Return the new number from the function.
 Print the new number.
Example:
If num is 12, and n is 3, in circular_right_shift fuction
12 > 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0
new number > 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 
Prerequisites:
 Loops
 Bitwise Operators
 Type Modifiers
 Functions
Objective:
 To understand the concept of
 Functions
 Bitwise Operators
Inputs:
 Integers N, S
Sample Execution / Output:
Test Case 1:
Description:
 In mathematics, the Fibonacci numbers or Fibonacci sequence are the numbers in the following integer sequence
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 . . .
OR
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 . . .  By definition, the first two numbers in the Fibonacci sequence are either 1 and 1, or 0 and 1, depending on the chosen starting point of the sequence, and each subsequent number is the sum of the previous two.

Prerequisites:
 Loops
 Arithmetic Operators
 Recursions
Objective:
 To understand the concept of
 Recursive Functions
Inputs:
 Integers N
Sample Execution / Output:
Test Case 1:
Test Case 2: Positive Numbers
Test Case 3: Negative Number
Test Case 4: Negative Number
Description:
 Read number n from user.
 Validate the given number
 Call main function from main for calculating factorial.
 Prompt for continue option.

Prerequisites:
 Storage Classes
 Recursions
Objective:
 To understand the concept of
 Recursion and static keyword
Inputs:
 Integers N
Sample Execution / Output:
Test Case 1:
Test Case 2:
Test Case 3:
Description:
 Read_int function should exactly behave like scanf(“%d”, &i)
 Implement read_int fuction without using scanf function.
Prerequisites:
 Functions
 Pointers
Objective:
 To understand the concept of
 Functions and Pointers
Inputs:
 An integer
Sample Execution / Output:
Test Case 1:
Description:
 Read the choice from user.
 float or double
 Read the fractional number from user.
 Print the bits of the entered number.
Prerequisites:
 Loops
 Bitwise Operators
 Type Casting
 Functions
 Pointers
Objective:
 To understand the concept of
 Type Casting
 Functions
 Type casting on Pointers
 IEEE Standard representation
Inputs:
 A real number
Sample Execution / Output:
Test Case 1:
Description:
In recreational mathematics, a magic square is an arrangement of distinct numbers (i.e. each number is used once), usually integers, in a square grid, where the numbers in each row, and in each column, and the numbers in the main and secondary diagonals, all add up to the same number
A magic square has the same number of rows as it has columns, and in conventional math notation, “n” stands for the number of rows (and columns) it has.
Thus, a magic square always contains n2 numbers, and its size (the number of rows [and columns] it has) is described as being “of order n”.
Example: if n = 3, the magic square
6
8  1  
3  7  5 
4  9  2 
 Read an odd number n from user.
 Do error checking.
 Check the number is odd or not.
 If not, continue step a.
 Create an n X n matrix.
 Insert 1 to (n * n) numbers into matrix.
 Arrange the numbers in such a way that, adding the numbers in any direction, either rowwise column wise or diagonal wise, should result in same answer.
Prerequisites:
 Loops
 Arrays
 Pointers
Objective:
 To understand the concept of
 2D Arrays
 Pointers on 2d arrays
Inputs:
 An integer N
Sample Execution / Output:
Test Case 1:
Description:
 Read number a from user.
 Read number b from user.
 Call a swap function by passing address of both a & b.
 After swap function, a and b values should get swapped.
 Prompt for continue option.
Prerequisites:
 Functions
 Pointers
Objective:
 To understand the concept of
 2’s Compliment and Bitwise Operators
Inputs:
 2 Integers N1 and N2
Sample Execution / Output:
Test Case 1:
Description:
 Pass a number ‘N’ from command line.
 If no numbers are entered through command line, read from user.
 Read the type of increment from user like menu drive.
 post increment
 pre increment
 Call the corresponding functions
 Return values of the functions should exactly behave as ++num and num++ operations
 We should use ++ operator in this program.
 With the help of bitwise operator we increment the given value.

Example: –
If num is 5,i = pre_increment(&num);
printf(“i = %d\n num = %d\n”, i, num);should print,
i = 6, num = 6If num is 5,
i = post_increment(&num);
printf(“i = %d\n num = %d\n”, i, num);should print,
i = 5, num = 6
Prerequisites:
 Bitwise operators
 pointers
Objective:
 To understand the concept of
 To understand the concept of pre and post increment using bitwise
Inputs:
 Integer N
Sample Execution / Output:
Test Case 1:
Description:
 I^{st} method
 Read number n from user.
 Read n numbers from user.
 Calculate average of entered numbers and print it on the screen.
 II^{nd} method

 Pass the numbers (for which average to be calculated) through command line.
 Collect them in main
 Calculate the average of them.
Hint : Use atoi function to convert string to integers.

 III^{rd} method

 Pass the numbers (for which average to be calculated) through environment variables.
 Collect them in main
 Calculate the average of them.
Hint :
Use atoi function to convert string to integers.
Use strtok to split the strings.Example : From shell export a variable which contain numbers.
export arr=”1 2 3 4″In main program receive this by third argument of main. Extract numbers from string and calculate their average.

Prerequisites:
 Main Prototypes
 Arrays and Pointers
Objective:
 To understand the concept of
 Arrays and pointers
Inputs:
 Array on N integers, N
Sample Execution / Output:
Test Case 1:
Test Case 2:
Test Case 3:
Description:
 int getword(char *word)
 Create a function named getword.
 Function should read a string from user and store them in the char address.
 Function should return the length of word.
 int atoi(const char *s)
 The function will recieve a string and covert the number stored in the string into exact integer number.
 Return the number.
 int itoa(int n, char *s)
 Convert integer n into a string and store the string in s.
 Return the length of string from the function.
Prerequisites:
 Functions
 Pointers
Objective:
 To understand the concept of
 Functions and Pointers
Inputs:
 String, String and Integer
Sample Execution / Output:
Test Case 1:
Test Case 2:
Test Case 3:
Test Case 4:
Test Case 5:
Test Case 6:
Description:
 Read string1 and string2 from user
 Provide the Display menu
 string compare
 string case compare
 Call the corresponding function for example : my_strcmp (string1, string2)
 Should return integer number which indicates both string are equal or not
Prerequisites:
 Strings
 Pointers
Objective:
 To understand the concept of
 Strings functions
Inputs:
 2 Strings
Sample Execution / Output:
Test Case 1:
Test Case 2:
Description:
 Read string1 and string2 from user.
 Call my_strtok (string1, string2);
 Should treat string2 as delimitter in string1 and should return 1st field.
 If you call again my_strtok (NULL, string2), it should return second field in string1 treating string2 as delimitter.
Prerequisites:
 Storage Classes
 Strings
 Pointers
Objective:
 To understand the concept of
 Strings functions
Inputs:
 2 Strings
Sample Execution / Output:
Test Case 1:
Description:
 Check the memory assigning order of variables for checking whether little endian or big endian machine
Little Endian:
————–
Say int i = 10; gets stored in memory at1000
1001
1002
1003where 1000 contains LSB of i and 1003 contains MSB of ichar *ptr = &i; the ptr will now contain 1000
Big Endian:
———–
Say int i = 10; gets stored in memory at1000
1001
1002
1003where 1000 contains MSB of i and 1003 contains LSB of i
char *ptr = &i; the ptr will now contain 1000
Fetch the values pointed by ptr for knowing whether they stored as little endian or big endian format.
Prerequisites:
 Pointers
Objective:
 To understand the concept of
 Strings functions
Inputs:
 2 Strings
Sample Execution / Output:
Test Case 1:
Description:
 In probability theory and statistics, variance measures how far a set of numbers is spread out. A variance of zero indicates that all the values are identical. Variance is always nonnegative: a small variance indicates that the data points tend to be very close to the mean (expected value) and hence to each other, while a high variance indicates that the data points are very spread out around the mean and from each other
Example:
x(input)  D = X – Mean  D^{2} 
9  11  121 
12  8  64 
15  5  25 
18  2  4 
20  0  0 
22  2  4 
23  3  9 
24  4  16 
26  6  36 
31  11  121 
Sum = 200  Sum=400  
Mean = (sum of x) / size  
where : size = Number of items in the input  
Formula to calulate the variance:  
sigma = (sum of D2) / size 
Prerequisites:
 Functions
 Pointers
 Static Arrays
Objective:
 To understand the concept of
 Functions and Pointers
 Static Functions
Inputs:
 Array of N Integers, N
Sample Execution / Output:
Test Case 1:
Description:
 Run a loop for printing the float elements in sorted order.
 Read the float elements from user and store them into an array.
Prerequisites:
 Functions
 Arrays
 Pointers
Objective:
 To understand the concept of
 Functions, Arrays, and Pointers
Inputs:
 Array on N floats, N
Sample Execution / Output:
Test Case 1:
Description:
 Read the N name from the user
 Sort it in alphabetical order
Prerequisites:
 Functions
 Static / Dynamic Arrays
 Pointers
Objective:
 To understand the concept of
 Functions, Arrays, and Pointers
Inputs:
 Array on N names, and Pointers
Sample Execution / Output:
Test Case 1:
Description:
 Input string:
Pointers are sharp knives.  Output String:
Pointers are sharp knives.
Prerequisites:
 Functions
 Pointers
 Dynamic Arrays
Objective:
 To understand the concept of
 Functions, Arrays, and Pointers
Inputs:
 String with multispaces between words
Sample Execution / Output:
Test Case 1:
Description:
 char *my_strstr(const char *haystack, const char *needle);
 The my_strstr() function finds the first occurrence of the substring needle in the string haystack.
 The terminating null bytes (‘\0’) are not compared.
 Return Value:
 These functions return a pointer to the beginning of the substring, or NULL if the substring is not found.
Prerequisites:
 Functions
 Pointers
 Arrays
Objective:
 To understand the concept of
 Functions, Arrays, and Pointers
Inputs:
 String (Haystack) and Substring (needle)
Sample Execution / Output:
Test Case 1:
Description:
 Read a string from user.
 Without modifying that string, print it in reverse order.
 Implement in both recursive and nonrecursive methods.
Prerequisites:
 Recursion
Objective:
 To understand the concept of
 Recursion
Inputs:
 String
Sample Execution / Output:
Test Case 1:
Description:
 Read two strings s1 and s2 from user.
 Remove the characters in s1 that matches with s2.
 Input string:
 string 1: Dennis Ritchie
 string 2: Linux
 Output String:
 After squeeze s1: Des Rtche
Prerequisites:
 Functions
 Pointers
 Arrays
Objective:
 To understand the concept of
 Functions
 Pointers & strings
 Arrays
Inputs:
 String 1 and String 2
Sample Execution / Output:
Test Case 1:
Description:
 Enter the number of elements to store in the array through the command line
 Read the type of data to store
 Enter the elements into the array.
 Pass them to calc mean function
 Should return mean value.
Prerequisites:
 Functions
 Void Pointers
 Arrays
Objective:
 To understand the concept of
 Functions
 Void Pointers
 Arrays
Inputs:
 Array of N elements, No of elements N, Size Option T,
Sample Execution / Output:
Test Case 1:
Description:
 Read characters from user till EOF
 If EOF received, print the character count, word count, and line count.
Prerequisites:
 Non formated function like getchar()
Objective:
 To understand the concept of
 Standard output
Inputs:
 A string with CtrlD
Sample Execution / Output:
Test Case 1:
Description:
 Take two file names through command line
 Do error checking.
 Check command line args
 Check file open status
 Open first file in read mode
 Open second file in write mode
 Copy first file contents into second file.
Prerequisites:
 file operation functions like fopen, fgets etc
Objective:
 To understand the concept of
 File handling in C
Inputs:
 Source File and a Destination File
Sample Execution / Output:
Test Case 1:
Test Case 2:
Description:
 Take an existing filename from user through command line
 Do error checking.
 If user passed any filename through command line or not.
 If passed, check the fopen success or not.
 Read Characters from file till EOF.
 If EOF reached, print the word count.
Prerequisites:
 file operation functions like fopen, fgets etc
Objective:
 To understand the concept of
 File handling in C
Inputs:
 Source File
Sample Execution / Output:
Test Case 1:
Test Case 2:
Description:
 Receive file names through command line.
 Do error checking.
 cmd line args
 fopen status
 if cmd line args are ./a.out
 then print stdin buffer contents into stdout buffer.
 If cmd line args are ./a.out file1 file2
 then print file1 and file2 contents to stdout.
 If cmd line args are ./a.out file1 file2 file3
 then print file1 and file2 contents into file3.
 Use a common function for doing file copy.
Prerequisites:
 file operation functions like fopen, fgets etc
Objective:
 To understand the concept of
 File handling in C
Inputs:
 Source File, Destination File
Sample Execution / Output:
Test Case 1:
Test Case 2:
Test Case 3:
Description:
 Treat address of x and address of x + 1as characters address.
 Both addresses difference will be sizeof x
Prerequisites:
 Macros
 Pointers
Objective:
 To understand the concept of
 Macros in preprocessing
Inputs:
 None
Sample Execution / Output:
Test Case 1:
Description:
 Implement swap concept with the help of macro
 The type of arguments to swap will be passed as t
 swap (int, x, y) where x and y are of types int.
Prerequisites:
 Macros
Objective:
 To understand the concept of
 Macros in preprocessing
Inputs:
 Integers N1 and N2
Sample Execution / Output:
Test Case 1:
Description:
 Allocate 8 consecutive bytes in memory
 Provide a display menu
 Add element
 Remove element
 Display element
 Exit from the program
 It should allow to add elements of different data types which data type size is less than or equal to 8
Prerequisites:
 Pointers
 Dynamic memory allocation
Objective:
 To understand the concept of
 Dynamic memory allocation
Inputs:
 Integers N1 and N2
Sample Execution / Output:
Test Case 1:
Description:
 Enter the length of array from command line.
 Read the type of data to search
 Initialise the array of mentioned type with variables read from user.
 Read the key element to search
 Sort the element in ascending order.
 Return the position of element in the array.
Prerequisites:
 Void pointer concepts
 Function pointer concepts
 Functions and arrays
Objective:
 To understand the concept of
 Function and void pointers
Inputs:
 Array on N elements, N, Data type T, Element to be searched K
Sample Execution / Output:
Test Case 1:
Description:
 int my_scanf (const char *format, …);
 The scanf() function reads input from stdin (the standard input stream).
Return value
 Upon successful return, these function return the number of input item successfully matched and assigned
Prerequisites:
 Variadic Functions
 Pointers
Objective:
 To understand the concept of
 Variadic Function
Inputs:
 As passed to standard scanf() function
Sample Execution / Output:
Test Case 1:
Description:
 Tower of hanoi consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.
 The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules :
 Only one disk can be moved at a time.
 Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack (i.e) a disk can only be moved if it is the uppermost disk on a stack.
 No disk may be placed on top of a smaller disk.
Prerequisites:
 Recursions
Objective:
 To understand the concept of
 Recursions
Inputs:
 Number of disks N
Sample Execution / Output:
Test Case 1:
Description:
 Suppose k = 3 (say taking 3 distinct characters ).
 Let 3 distinct characters be a , b, c.
 Suppose ‘n’ is the string length to be formed using ‘k’ distinct words.
 Let n be 6
 The string should be formed in such a way that there should not be any consecutive repetitions of the strings.
Prerequisites:
 Strings
 Pointers
 Arrays
Objective:
 To understand the concept of
 String manupulations
Inputs:
 No of character C, Length of the string N and C disctint characters
Sample Execution / Output:
Test Case 1: