Skip to content

My first 100 days of code with C as the primary language. This coding journey will help you to crack interviews and programming rounds.

Notifications You must be signed in to change notification settings

sanjay-rb/100-Days-of-Code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Day1 - Addition of two numbers

Write a C program to perform addition of 2 integer numbers.

Day2 - Area and Circumference of a Circle

Write a C program to calculate Area and Circumference of a Circle

Day3 - Multiplication and Division

Write a C program to perform Multiplication and Division of Fractional numbers

Day4 - Swapping of 2 numbers

Write a C program for swapping of 2 numbers with a temporary variable

Day5 - Area of Triangle

Write a C program to find the area of a Triangle using three sides

Day6 - Leap year Check

Write a C program to check whether the entered year is leap year or not

Day7 - Surface Area and Volume of a Cube

Write a C program to find the surface area and volume of a cube using pow() method

Day8 - Prime Number Check

Write a C program to check whether the entered number is prime number or not?

Day9 - Sum and Avg

Write a C program to find Sum and Average of 10 numbers

Day10 - Amicable Pair Check

Write a C program to check whether the entered pair of numbers are Amicable numbers or not? What is Amicable Pair?

let's consider 2 numbers A & B, first you need to generate the proper divisors of A, then sum it, then generate the proper divisors of B, then sum it, if A's sum of proper divisors equals to B and B's sum of proper divisors equals to A means we can call the pair of numbers as Amicable Pair. 
Eg: A=220 and B=284
They are amicable pair because the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110, of which the sum is 284; and the proper divisors of 284 are 1, 2, 4, 71 and 142, of which the sum is 220.

Day11 - Swapping of 2 numbers using Pointers

Write a C program to swap two numbers using pointers

Day12 - Finding ASCII value of a character

Write a C program to find an ASCII value of an input

Day13 - Vowel and Consonant Check

Write a C program to check the entered character is Vowel or Consonant

Day14 - Relationship between Arrays & Pointers

Write a C program to show relationship between Arrays and Pointers

Day15 - Dynamic Memory Allocation

Write a C Program to Demonstrate the concept of Dynamic Memory Allocation using malloc().

Day16 - Simple Date

Write a C program for handling Date

Accept the three date components as an integer through keyboard

Validate date and month-> not more than 31 & 12

Display the date details in MM-DD-YYYY format

Day17 - Simple Date-II

Write a C program for Demonstrating Simple Date(V 2.0)

Accept the three date components as an integer through keyboard, format should be DD for Date, MM for Month and YY for Year

Validate date, month & year-> not more than 31 & 12 and year must be in YY format

Ask the user to choose the century as you get the year in YY format-> 19th Century / 20th Century / 21st Century

Ask the user to choose the format for the Date-> MM-DD-YYYY / DD-MM-YYYY / YYYY-MM-DD

Day18 - Simple Date-III

Write a C program for Demonstrating Simple Date(V 3.0)

Accept the three date components as an integer through keyboard, format should be DD for Date, MM for Month and YY for Year

Validate date, month & year-> not more than 31 & 12 and year must be in YY format

Ask the user to choose the century as you get the year in YY format-> 19th Century / 20th Century / 21st Century

Ask the user to choose the format for the Date-> MM-DD-YYYY / DD-MM-YYYY / YYYY-MM-DD

Ask the user to enter the number of days he/she want to add, then print the result on the console by considering the the increment of month as well as year

Please do not have consideration for leap year

Day19 - Simple Date-IV

Write a C program for Demonstrating Simple Date(V 4.0)

Accept the three date components as an integer through keyboard, format should be DD for Date, MM for Month and YY for Year

Validate date, month & year-> not more than 31 & 12 and year must be in YY format

Ask the user to choose the century as you get the year in YY format-> 19th Century / 20th Century / 21st Century

Ask the user to choose the format for the Date-> MM-DD-YYYY / DD-MM-YYYY / YYYY-MM-DD

Ask the user to enter the number of days he/she want to add, then print the result on the console by considering the the increment of month as well as year

Please have the consideration for leap year

Have a looping construct to iterate add days part with this version-> Option 1(Yes) to continue and Option 2(No) to quit-> refer the sample output

Day20 - Prime Fibonacci Numbers

Write a C program to Generate Prime Fibonacci Numbers for a given range of fibonacci series

Accept the range as an integer

When you enter the range of fibonacci numbers, don't consider the first two fibonacci numbers(i.e. 0 & 1)-> so first 10 fibonacci numbers are 1,2,3,5,8,13,21,34,55,89

it's upto you to build the logic by adopting the concept of modularity

Day21 - Output Generation-I

Write a C program to Generate the following output

1 
234 
56789

1 to 9 must be printed by a loop. In first row 1 number, second row 3 numbers and

Day22 - Factorial using Recursion

Write a C program for finding factorial of a given number by using recursion.

Make sure you should use a user defined find_fact(int)

function and that should call itself for factorial calculation

Day23 - Output Generation-II

Write a C program to Generate the following output

* $ $ $ $ 
$ * $ $ $ 
$ $ * $ $ 
$ $ $ * $ 
$ $ $ $ * 

every loop iteration must show 4 $s and diagonals should be *(all must be separated by spaces)

Day24 - Output Generation-III

Write a C program to Generate the following output

* 
*** 
***** 
******* 
********* 

every loop iteration must show asterisk(s), first iteration 1, second iteration 3, third iteration 5 and so on.

Day25 - Output Generation-IV

Write a C program to Generate the following output

# # # # #
# # # # #
# # 0 # #
# # # # #
# # # # #

Day26 - Array Traversal-I Search an element in the given array

Write a C program to search an element in an array.

Assume you gonna use an integer array

Get the size of the array from the user

Allocate the memory dynamically through the use of calloc() call

Get the element to be searched from the user and traverse through the array elements

Day27 - Array Traversal-II Positive and Negative numbers separation

Write a C program to separate positive and negative numbers using arrays

Get the size of an array from user, assume you gonna work with integer arrays

Get the elements through keyboard, make sure at-least 30% of the elements should be negative numbers

Finally display positive numbers and negative numbers separately in an ascending order.

Day28 - Array Traversal-III

Write a C program to perform the following using Arrays,

get the size of an array from user, assume you gonna work with integer arrays

write 4 user defined functions for

  • to display the array contents in an ascending order
  • to display the array contents in a descending order
  • to display the second largest element in an array
  • to display the second smallest element in an array

Day29 - Reverse a text

Write a C program to read a line of text and reverse it using recursive function

get a char array of meaningful data from the user and pass it to a recursive function, let the function read it and reverse it by traversing through the array elements and finally mention the palindrome status

Day30 - Array Traversal-IV

Write a program in C to print all unique elements in an array.

Day31 - Array Traversal-V

Write a C program to count the frequency of each element of an array.

Day32 - Array Traversal-VI

Write a C program to find the sum of all elements of the array.

Day33 - Array Traversal-VII

Write a C program to delete an element from an array in a menu driven fashion.

You should go for options(Insert, Delete, Display, Exit)

Day34 - Array Traversal-VIII

Write a C program to print odd positioned array elements(only prime numbers) and even positioned array elements(only prime numbers) separately and print their summations.

get the size of an array from user, assume you gonna work with integer arrays

consider index zero as an even number

don't consider 1 as a prime number

your logic should work for both 10 inputs and 5 inputs

have some considerations for non-prime numbers as well

Day35 - Array Traversal-IX

Write a C program to merge two arrays of same size sorted in descending order.

get the size of the arrays from user, assume you gonna work with integer arrays

I kept one special test case of array size mismatch- so have a special care for array size-> if the size of the first array is not matched with the size of the second array, you should print "make sure both the arrays must be with the same size1

Day36 - Array Traversal-X

Write a C program to insert a new value in the array(unsorted list)

get the size of the arrays from user, assume you gonna work with integer arrays

Make sure your array must be flexible enough for at least one insertion

Day37 - Array Traversal-XI

Write a C program to insert a new value in the array(sorted list)

get the size of the arrays from user, assume you gonna work with integer arrays

you don’t need to ask the user to input the position

Make sure your array must be flexible enough for at least one insertion

Day38 - Sum of digits

Write a C program to accept either string/integer and find sum of digits in it

accept the input through keyboard

your logic should work for both string and integer

for string, substitute number equivalent for alphabets, 1 for a, 2 for b,….,26 for z

make sure the final output should be a single digit number-> 18767986->1+8+7+6+7+9+8+6->52->5+2-> 7

Day39 - Output Generation-V

Write a C program to Generate the following output

be conscious about number of spaces between asterisks

iterations 1 to 5 should be 18 to 2(difference should be 4)

iterations 1 to 6 should be 22 to 2(difference should be 4)

5

*                  *
* *              * *
* * *          * * *
* * * *      * * * *
* * * * *  * * * * *
* * * * *  * * * * *
* * * *      * * * *
* * *          * * *
* *              * *
*                  *

Day40 - Output Generation-VI

Write a C program to Generate the following output

be conscious about number of spaces between asterisks

1 to 7 should be 2 to 26(difference should be 4)

iterations 1 to 5 should be 2 to 18(difference should be 4)

 5
* * * * *  * * * * *
* * * *      * * * *
* * *          * * *
* *              * *
*                  *
*                  *
* *              * *
* * *          * * *
* * * *      * * * *
* * * * *  * * * * *

Day41 - Zero Sum Subarray

Write a C program to find any subarray that sums to zero, if one exists.

Day42 - String Processing-I

Write a C program to check if the string contains consecutive letters and each letter occurs exactly once.

Get the sequence of alphabets through console

be specific with the output format, refer all the Sample Inputs and Sample Outputs for more clarity

Day43 - String Processing-II

Write a C program to find the ASCII values summation of vowels in the given string

Get the sequence of alphabets through console

Make sure your logic should work for both uppercase and lowercase

Day44 - String Processing-III

Write a function that returns the index where a character, c, occurs in a string, s. The function returns -1 if c is not present in s. Use array indexing.

Day45 - String Processing-IV

Write a function that returns the index where a character, c, occurs in a string, s. The function returns -1 if c is not present in s. Use array indexing.

your logic should work for repetitive characters in a given string

Day46 - String Processing-V

Write a C program with a function that takes two strings, s and t, as arguments. Copy string s into t, but remove all white space(meaningless)and punctuation. Use array indexing.

Output:

Enter the String
Don't go outside,temperature may go high up-to 36degrees today.

o/p - Dont go outside temperature may go high upto 36degrees today 

Day47 - String Processing-VI

Write a function that detects the presence of a whole word in a string.

Output:-

Positive TestCase:-

Enter the String
 Hey this is Sanjay!!!
 Hey
the search word is found

Negative TestCase:-

Enter the String
 Hey this is Sanjay!!!
 sanju
the search word is not found

Day48 - String Processing-VII

Write a C program to checks if a string is a palindrome by ignoring all white spaces.

Output:-

Positive Testcase:-

Enter the String
i ia wah hawaii
The entered string is a palindrome string

Negative Testcase:-

Enter the String
Sanjay Babu
The entered string is not a palindrome string

Day49 - Bubble Sort

Write a C program for Bubble sort.

Output:-

11
12
22
25
34
64
90

Day50 - 2D Array-I

Write a C program to calculate the sum of all the elements in a matrix

get the number of rows and column information from the use

Output:-

Enter the no. of rows
 3
Enter the no. of columns
 3
insert the element for 0,0 1
insert the element for 0,1 2
insert the element for 0,2 3
insert the element for 1,0 4
insert the element for 1,1 5
insert the element for 1,2 6
insert the element for 2,0 7
insert the element for 2,1 8
insert the element for 2,2 9
The matrix is
1 2 3 
4 5 6 
7 8 9 
Sum of all the elements -> 45 

Day51 - 2D Array-II

Write a C program to extract the diagonal elements from the matrix and sum it.

we are gonna work with nxn matrix

Output:-

Positive Testcase:-

Enter the no. of rows
 3
Enter the no. of columns
 3
insert the element for 0,0 1
insert the element for 0,1 2
insert the element for 0,2 3
insert the element for 1,0 4
insert the element for 1,1 5
insert the element for 1,2 6
insert the element for 2,0 7
insert the element for 2,1 8
insert the element for 2,2 9
The matrix is
1 2 3 
4 5 6 
7 8 9 
Diagonal elements are ->1,5,9,3,5,7
Sum of all the elements -> 30 

Negative Testcase:-

Enter the no. of rows
 2
Enter the no. of columns
 3
Make sure your input matrix should be in nxn format

Day52 - 2D Array-III

Write a C program to interchange the main diagonal elements with secondary diagonal elements.

We are gonna work with 3x3 matrix

Output:-

Positive Testcase:-

Enter the no. of rows
 3
Enter the no. of columns
 3
insert the element for 0,0 1
insert the element for 0,1 2
insert the element for 0,2 3
insert the element for 1,0 4
insert the element for 1,1 5
insert the element for 1,2 6
insert the element for 2,0 7
insert the element for 2,1 8
insert the element for 2,2 9
The matrix is
1 2 3 
4 5 6 
7 8 9 
Main Diagonal elements are ->1,5,9
Secondary Diagonal elements are ->3,5,7
After interchange, the final matrix is
3 2 3 
4 5 6 
7 8 7 

Negative Testcase:-

Enter the no. of rows
 3
Enter the no. of columns
 2
Make sure your input matrix should be in 3x3 format

Day53 - 2D Array-IV

Write a C program to check whether the matrix is Sparse matrix or not.

Sparse matrix is a special matrix with most of its elements are zero.

The matrix is sparse matrix if T ≥ ((m * n) / 2 ); where T defines total number of zero elements, m - no. of rows and n - no. of columns.

get the number of rows and column information from the user, make sure you gonna work with arbitrary sized matrix.

Output:-

Positive Testcase:-

Enter the no. of rows
 3
Enter the no. of columns
 3
insert the element for 0,0 0
insert the element for 0,1 1
insert the element for 0,2 0
insert the element for 1,0 2
insert the element for 1,1 0
insert the element for 1,2 5
insert the element for 2,0 0
insert the element for 2,1 1
insert the element for 2,2 0
The matrix is
0 1 0 
2 0 5 
0 1 0 
The given matrix is a sparse matrix.

Negative Testcase:-

Enter the no. of rows
 3
Enter the no. of columns
 3
insert the element for 0,0 0
insert the element for 0,1 1
insert the element for 0,2 5
insert the element for 1,0 9
insert the element for 1,1 0
insert the element for 1,2 5
insert the element for 2,0 4
insert the element for 2,1 2
insert the element for 2,2 1
The matrix is
0 1 5 
9 0 5 
4 2 1 
The given matrix is not a sparse matrix.

Day54 - 2D Array-V

Write a C program to find the sum of each row and column of a matrix

Output:-

Enter the no. of rows
 2
Enter the no. of columns
 3
insert the element for 0,0 1
insert the element for 0,1 2
insert the element for 0,2 3
insert the element for 1,0 3
insert the element for 1,1 2
insert the element for 1,2 1
The matrix is
1 2 3 
3 2 1 
Sum of row1->6
Sum of row2->6
Sum of column1->4
Sum of column2->4
Sum of column3->4

Day55 - Array-Left Rotate

Write a C program to left rotate an array by n position.

Output :-

Enter the size of the array
 5
Input 5 numbers
 4
 5
 6
 7
 8
Input number of times to rotate
 3
Array after left rotation 3 time(s)
7
8
4
5
6

Day56 - Array-Left & Right Rotate

Write a C program to left rotate an array by n position and right rotate by n position in a menu driven fashion.

Output :-

LeftShift Testcase:-

Enter the size of the array
 5
Input 5 numbers
 1
 2
 3
 4
 5
Want to perform left rotate or right rotate?
1.Left rotate
2.Right rotate 
 1
Input number of times to rotate
 2
Array after left rotation 2 time(s)
3
4
5
1
2

RightShift Testcase :-

Enter the size of the array
 5
Input 5 numbers
 1
 2
 3
 4
 5
Want to perform left rotate or right rotate?
1.Left rotate
2.Right rotate 
 2
Input number of times to rotate
 2
Array after right rotation 2 time(s)
4
5
1
2
3

Day57 - Trailing Zeros

Write a C program to count number of trailing zeros in the binary representation of an integer. Using the Bitwise Operator.

Output:-

Enter the integer
 8
Binary equivalent of 8 is 00001000
Number of trailing zeros in its binary representation is 3

Day58 - String Processing-VIII

Write a C program to make a palindromic string non-palindromic by rearranging its letters.

Get a char array from the user

print the string after rearranging some characters such that the string becomes non-palindromic,if it’s impossible then print -1

Output:-

Enter the string
 amma
aamm

Day59 - Capitalize first and last letter of each word

Write a C program to capitalize the first and last letter of each word in an input line.

get the char array input thru console, consider you’re getting input in lower case

for two-letter word, both needs to be capitalized

Output:-

Enter the string
 hello all,hope things are going well
HellO AlL,HopE ThingS ArE GoinG WelL 

Day60 - Finding Subarray with given sum

Write a C program to find a subarray which sums to an input sum.

Get the array length and sum from the user through console.

Refer sample input and output thoroughly.

Subarray- sequence of elements(not jumping indices)

Output:-

Enter array length and sum respectively
8
20
enter 8 elements
4
2
10
3
-3
10
5
5
Subarray is 10 3 -3 10

Day61 - Perfect Number

Write a C program to check whether a number is perfect number or not.

Perfect number is a positive integer which is equal to the sum of its proper positive divisors.
for example, 6 is a perfect number,because proper divisors of 6 are 1,2,3, so 1+2+3=6.

Output:-

Enter the number
 28
28 is a perfect number

Day62 - Strong Number

Write a C program to generate Strong numbers from 1 to 1000.

Strong number is a special number whose sum of factorial  of digits is equal to the original number. For example, 145 is a strong number, because 1! + 4! + 5! = 145

Output:-

Enter the limit
 1000
1,2,145 are Strong numbers between 1 & 1000

Day63 - Run Length Encoding-I

Write a C program to print the frequency of letters in a String using run-length encoding.

Run-length encoding(RLE) is a very simple form of lossless data compression in which runs of data

Output:-

Enter the input string
 wwwwaaadexxxxxx
RLE result is 4w3a1d1e6x 

Day64 - Run Length Encoding-II

Write a C program to print the frequency of letters in a String using run-length encoding.

Run-length encoding(RLE) is a very simple form of lossless data compression in which runs of data

Make sure your logic should work for both uppercase and lowercase letters

Output:-

Enter the input string
 AAaaBBcccdeEFfGGhh
RLE result is 2A2a2B3c1d1e1E1F1f2G2h 

Day65 - Run Length Encoding-III

Write a C program to print the frequency of letters and numbers in a String using run-length encoding.

Run-length encoding(RLE) is a very simple form of lossless data compression in which runs of data

Make sure your logic should work for both uppercase, lowercase letters and digits

limit the number sequences to 5

Output:-

Enter the input string
 11111uuKkkllMM2229999awWE
RLE result is five12u1K2k2l2Mthree2four91a1w1W1E 

Day66 - Larger Elements

Write a C program to find number of larger elements on right side in a string

Accept a char array from the user

If the input string is “abcd”, then the output is 3 2 1 0, because there are 3 greater characters on right of 'a', 2 greater characters on right of 'b', 1 greater character on right of 'c' and 0 greater characters on right of 'd'

Output:-

Enter the String
 computer
7 4 4 3 0 0 1 0  

Day67 - Number of ways to reach given score in a game

Write a C program to count number of ways to reach a score using 1 and 2 with no consecutive 2s.

A cricket player has to score N runs, with condition he can take either 1 or 2 runs only and consecutive runs should not be 2. Find all the possible combination he can take. For example, if input is 4, then output is also 4, because the following 4 combinations are possible to reach the score 4, 1+1+1+1, 1+2+1, 2+1+1, 1+1+2.

Output:-

Enter the score
 5
6 possible ways 

Day68 - Replace Duplicates

Write a C program to Replace duplicates with greater than previous duplicate value

Given an array of elements and change the array in such a way that all the elements on the array are distinct.

if you are replacing a value, then the replacing value should be great than the previous value and after modification sum of the elements should be as less as possible.

Output:-

Enter the size of the array
 10
Enter 10 elements
 1
 2
 2
 3
 5
 5
 5
 5
 1
 8
Result after replacing duplicates
1
2
3
4
5
6
7
8
1
8

Day69 - Rearranging elements

Write a C program to rearrange odd and even values in alternate fashion in Ascending order.

Given an array of integers (both odd and even),the task isto arrange them in such a way that odd & even values come in alternate fashion in non-decreasing order(ascending) respectively.

If the smallest value is Even then we have to print Even-Odd pattern.

If the smallest value is Odd then we have to print Odd-Even pattern.

Get the input from the user, No. of odd elements must be equal to No. of even elements in the input array.

Output:-

Enter the size of the array
 6
Input 6 elements
 9
 8
 13
 2
 19
 14
Smallest value is 2, so output is Even-Odd pattern
2,9,8,13,14,19 

Day70 - Sum Triangle

Write a C program to print Sum Triangle for a given array

Given an array, construct a triangle where last row contains elements of given array, every element of second last row contains sum of below two elements and so on.

Output:-

Enter the size of the array
 8
Enter 8 elements
 4
 3
 9
 1
 0
 6
 5
 7
Sum Triangle is
417 
218 199 
125 93 106 
74 51 42 64 
41 33 18 24 40 
19 22 11 7 17 23 
7 12 10 1 6 11 12 
4 3 9 1 0 6 5 7 

Day71 - Smallest Pair

Write a C program to find smallest pair in an array

Given an array of distinct numbers, the task is to find a pair which has the minimum sum and print the sum

Output:-

Enter the size of the array
 4
Enter 4 elements
 5
 8
 2
 6
Smallest pair is [2,5]
Sum of the smallest pair is 7 

Day72 - Output Generation-VII

Write a C program to Generate the following output

be conscious about number of spaces

for Sample Input-I > from iterations 1 to 5 should be 8 to 0(difference should be 2)

for Sample Input-II > from iterations 1 to 7 should be 12 to 0(difference should be 2)

Output:-

 7
0            0
01          01
010        010
0101      0101
01010    01010
010101  010101
01010100101010

Day73 - Print the day

Write a C program to print whether the given date is weekday or weekend

Get the date from the user in DD-MM-YYYY format

If the entered date is 15-05-2019 means, output should be- Wednesday-Weekday

If the entered date is 23-03-2019 means, output should be- Saturday-Weekend

If the user enter an invalid date, output should be- please enter the date in proper format

Output:-

Enter the date
 17-05-2016
Tuesday-Weekday 

Day74 - Spiral Matrix

Write a C program to print spiral matrix.

Analyze and design a solution that will print the numbers as a spiral. For example for the given N x M matrix, where N is the number of rows and M is the number of columns, the number sequence will be from 1 to N x M.

Output:-

Enter the value for N
 3
Enter the value for M
 6
The final spiral matrix is
1 2 3 4 5 6 
14 15 16 17 18 7 
13 12 11 10 9 8

Day75 - Array Clockwise Rotation

Write a C program to rotate the array elements in clockwise rotation and print it.

Output:-

Enter the no. of rows
 3
Enter the no. of columns
 3
insert the element for 0,0
 1
insert the element for 0,1
 2
insert the element for 0,2
 3
insert the element for 1,0
 4
insert the element for 1,1
 5
insert the element for 1,2
 6
insert the element for 2,0
 7
insert the element for 2,1
 8
insert the element for 2,2
 9
The matrix is
1	2	3
4	5	6
7	8	9
Clockwise Rotation output is
4	1	2
7	5	3
8	9	6

Day76 - Array Anti-clockwise Rotation

Write a C program to rotate the array elements in anti-clockwise rotation and print it.

Output :-

Enter the no. of rows
 3
Enter the no. of columns
 3
insert the element for 0,0
 1
insert the element for 0,1
 2
insert the element for 0,2
 3
insert the element for 1,0
 4
insert the element for 1,1
 5
insert the element for 1,2
 6
insert the element for 2,0
 7
insert the element for 2,1
 8
insert the element for 2,2
 9
The matrix is
1	2	3
4	5	6
7	8	9
Anti-Clockwise Rotation output is
2	3	6
1	5	9
4	7	8

Day77 - Zero the edges

Write a C program that clears to zero all the edge elements of an MXN matrix.

get the number of rows and column information from the user, make sure you gonna work with MXN matrix

Output:-

Enter the no. of rows
 3
Enter the no. of columns
 3
insert the element for 0,0
 1
insert the element for 0,1
 2
insert the element for 0,2
 3
insert the element for 1,0
 4
insert the element for 1,1
 5
insert the element for 1,2
 6
insert the element for 2,0
 7
insert the element for 2,1
 8
insert the element for 2,2
 9
The matrix is
1	2	3
4	5	6
7	8	9
Result is
0	0	0
0	5	0
0	0	0

Day78 - Minimum absolute difference

Write a C program to find minimum absolute difference of a number and its closest prime.

Given a positive integer N, the task is to find the absolute difference of N and the prime number closest to N .The closest prime to N can be either less than, equal to or greater than N.

if N=25, then the output is 2.

because Closest prime greater than 25 is 29. So difference is 4. Closest prime less than 25 is 23. So difference is 2. The minimum of these two is 2.

if N is a prime number, then output should be.

Output:-

Enter the value for N
 987
Result is 4 

Day79 - Zigzag Traversal

Write a C program to print all elements of the given matrix in diagonal order. Make sure you gonna work with 2D array.

If this is an input array 
1	2	3	4
5	6	7	8
9	10	11	12
13	14	15	16
17	18	19	20
Output should be
1
5 2
9 6 3
13 10 7 4
17 14 11 8
18 15 12
19 16
20
because there are 8 diagonals

Output:-

Enter the no. of rows 4
Enter the no. of columns 3
insert the element for 0,0 1
insert the element for 0,1 2
insert the element for 0,2 3
insert the element for 0,3 4
insert the element for 1,0 5
insert the element for 1,1 6
insert the element for 1,2 7
insert the element for 1,3 8
insert the element for 2,0 9
insert the element for 2,1 10
insert the element for 2,2 11
insert the element for 2,3 12
The matrix is
1	2	3	4
5	6	7	8
9	10	11	12
Result is
1 
5 2 
9 6 3 
10 7 4 
11 8 
12 

Day80 - Closest smaller value

Write a C program to find closest smaller value for every element in an array.

Get the size and value for array elements through console.

Given an array of integers, find the closest smaller element for every element, if there is no smaller element then print -1.

Output:-

Enter the size of the array 6
Enter 6 integer elements 
10
5
11
6
20
12
Final output is
6 -1 10 5 12 11 

Day81 - Move special chars to end

Write a C program to move all the special characters to end of the string.

get the input string from the user through console

Give the consideration for following special characters ~,!,@,#,$,%,^,&,*,?

Output:-

Enter the input string
 T@e!c&&h@i*e N?e@r##d~~s&
 
The final output is 
Techie Nerds@!&&@*?@##~~& 

Day82 - Index pairs with equal elements

Write a C program to count total number of indices(i,j) such that arr[i]=arr[j] & i != j

In simple terms, in a given array of size n, count the index pairs with equal elements.

For eg, if the input array is {1,1,2}, then output is 1, because index 0 and index 1 holds the same value.

Get the array size and elements from the user through console.

Output:-

Enter the size of the array
 10
Input 10 elements 
 1
 1
 1
 2
 3
 3
 4
 4
 5
 5
Result is 5 

Day83 - Count pairs in an array

Write a C program to count pairs in array whose sum is divisible by k.

Given an array arr[] and a positive integer k, the task is to count total number of pairs in the array whose sum is divisible by k. for example, if arr[]={1,2,3,4,5,6} and k=3, then output is 5, because the following pairs’ sum divisible by k, (1,2), (1,5),(2,4),(3,6),(4,5).

Get the size of the array, array elements and the value of k through the console.

Output:-

Enter the size of the array
 6
Input 6 elements
 2
 2
 1
 7
 5
 3
Enter the value for k
 4
Result is 5 

Day84 - Longest Subsequence

Write a C program to find the longest subsequence such that adjacent elements have at-least one common digit.

Given an array arr[] of n integers, the task is to find the length of the longest sub-sequence such that adjacent elements of the sub-sequence have at least one digit in common.

Output:-

Enter the size of the array
 7
Enter 7 elements
 1
 12
 44
 29
 33
 96
 89
The longest subsequence is 1,12,29,96,89

Day85 - Minimising Array Sum

Write a C program to minimise array sum by subtracting larger elements from smaller ones.

Choose any two elements from the array say A and B where A>B and then subtract B from A

Output:-

Enter the size of the array
 5
Enter 5 elements
 1
 1
 2
 3
 4
Result is 5

Day86 - Unique Pairs

Write a C program to find number of unique pairs in an array.

Given an array arr[] of n elements, the task is to find all the unique pairs that can be formed using the elements of a given array.

for eg,
arr[] = {1,1,2}
then the output is 4, because (1,1),(1,2),(2,1) & (2,2) are the unique pairs.

Output:-

Enter the size of the array
 5
Enter 5 elements
 1
 1
 2
 2
 3
 
The following pairs are unique pairs
(1,1)
(1,2)
(1,3)
(2,1)
(2,2)
(2,3)
(3,1)
(3,2)
(3,3)
So the result is 9 

Day87 - Palindromic Partitions

Write a C program to print all the palindromic partitions in a given string.

Output:-

Enter the string
 jahangir
Palindromic partitions are
j a h a n g i r 
aha 

Day88 - Count Pairs(LCM)

Write a C program to Count pairs in an array such that LCM(arr[i], arr[j]) > min(arr[i],arr[j])

Given an array arr[], the task is to find the count of pairs from the array such that LCM(arr[i], arr[j]) > min(arr[i], arr[j])

Pairs (arr[i], arr[j]) and (arr[j], arr[i]) are considered identical and will be counted only once.

if arr[] = {1, 1, 4, 9}
then, Output is 5
Becasue, all valid pairs are (1, 4), (1, 9), (1, 4), (1, 9) and (4, 9)

Output:-

Enter the size of the array
8
Enter 8 elements
2
4
5
2
5
7
2
8
Result is 24

Day89 - Largest Number with Prime Digits

Write a C program to find largest number with prime digits.

Given an integer value for n, find the largest integer value x such that x<=n and all the digits of x are prime.

Output:-

Enter a number 
1000
Result is 777

Day90 - Make all numbers of an array equal

Write a C program to check whether we can make all numbers of an array equal.

Given an array arr[], the task is to make all the array elements equal with the given operation.

In a single operation, any element of the array can be either multiplied by 2 or by 3.

If its possible to make all the array elements equal with the given operation then print Yes else print No.

for example, 
if input is arr[]={50,75,100}
then output is Yes, because
{50 * 2 * 3, 75 * 2 * 2, 100 * 3} = {300, 300, 300}

Output:-

Enter the size of the array
3
Enter 3 elements
50
75
100
Yes, it’s possible to make all numbers of an array equal

Day91 - Largest Palindromic Number

Write a C program to find Largest Palindromic Number by permuting digits.

Given a very large input N, the task is to print the largest palindromic number obtained by permuting the digits of N.

If it is not possible to make a palindromic number, then print “Palindrome cannot be formed”

For Example
if the input is 313551, then the output is 531135, because 531135 is the largest number which is a palindrome, 135531, 315513 and other numbers can also be formed but we need the highest of all of the palindromes.

Output:-

Enter a number
531135
The largest palindromic number is 531135

Day92 - Cyclic Permutations

Write a C program to generate all cyclic permutations of a number.

Get the input through console.

Output:-

Enter a number
123
Possible cyclic permutations are
123
312
231

Day93 - Remove Consecutive Vowels

Write a C program to remove consecutive vowels from a given string.

Given a string s of lowercase letters, we need to remove consecutive vowels from the string.

Final output should not contain two consecutive vowels.

get the input string through console.

Output:-

Enter the string
i am very serious about my career

i am very seris abot my carer

Day94 - Circular Prime

Write a C program to check whether the given number is circular prime number or not and also generate the circular prime numbers from 1 to 1000.

A circular prime is a prime number with the property that the number generated at each intermediate step when cyclically permuting its (base 10) digits will be prime.

For example, 1193 is a circular prime, since 3119, 9311 and 1931 are prime numbers.

Output:-

Choose the option
 1.Check Circular Prime
 2.Generate Circular Prime numbers between 1 & 1000
 3.Exit
1
Enter a number
131

the entered number is a circular prime number

Day95 - Narcissistic Decimal Numbers

Write a C program to check whether the given number is Narcissistic Decimal Number or not and also generate first 15 Narcissistic Decimal Numbers.

Narcissistic Number is a number that is the sum of its own digits each raised to the power of the number of digits.

for example, 1634 is Narcissistic Number, because 1^4 + 6^4 + 3^4 + 4^4 = 1634.

Output:-

Choose the option
 1.Check Narcissistic Number
 2.Generate first 15 Narcissistic Numbers
 3.Exit
1
Enter a number
153
the entered number is a Narcissistic Number

Day96 - Automorphic Number

Write a C program to check whether the given number is Automorphic Number or not and also generate Automorphic Numbers between 1 & 1000.

A number is called Automorphic number if and only if its square ends in the same digits as the number itself.

for example, 76 is Automorphic Number, because 76 * 76 = 5776.

Output:-

Choose the option
 1.Check Automorphic Number
 2.Generate Automorphic Numbers between 1 & 1000
 3.Exit
 2
Automorphic Numbers between 1 & 1000 are
1 5 6 25 76 376 625 

Day97 - Pangram

Write a C program to display missing characters to make a string pangram.

Pangram is a sentence containing every letter in the english alphabet. Given a string, find all characters that are missing from the string, i.e., the characters that can make string a pangram.

The output should be in alphabetic order.

Output:-

Enter the string
 The quick brown fox jumps
The pangram result is
adglvyz 

Enter the string
 Mr. Jock, TV quiz PhD., bags few lynx.
The entered string is perfect pangram.

Day98 - Rearrange Characters

Write a C program to rearrange characters in a string such that no two adjacent are same.

get the input string through console(assume you gonna work with lowercase letters)

Output:-

Enter the string
 aaac
Not possible to rearrange 

Enter the string
 aaaaabccc
abacacaca 

Day99 - Longest Substring

Write a C program to find the longest sub-string which is prefix, suffix and also present inside the string.

Given a string str. The task is to find the longest sub-string which is a prefix, a suffix and a sub-string of the given string, str.

Output:-

Enter the string
 fixprefixsuffix
fix 

Day100 - Isogram Check

Write a C program to check whether the given string is isogram or not.

Isogram is a word in which no letters occurs more than once.

Output:-

Enter the string
 Sanjay
Sanjay is not an isogram 

Enter the string
 qwertyuiop
qwertyuiop is an isogram 

About

My first 100 days of code with C as the primary language. This coding journey will help you to crack interviews and programming rounds.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages