10 views
25 Jan 2026
* * *
* * * *
* *
* * * *
* * *
Sine wave simulation. Condition based on rows and columns: (i+j)%4 == 0 and (i+j)%4 == 2...
7 views
25 Jan 2026
* * * * *
* * * *
* * *
* *
*
* *
* * *
* * * *
* * * * *
Inverted triangle above, normal below. Mirror image vertically....
7 views
25 Jan 2026
*** ***
***** *****
***********
*********
*******
*****
***
*
Mathematical pattern - calculate specific coordinates where stars are printed....
7 views
25 Jan 2026
* * * * * *
* * * * * *
* * * * * * * *
* * *
* * *
* * * * * * * *
* * * * * *
* * * * * *
Complex pattern - middle row, middle column, and corners. By combining multi...
6 views
25 Jan 2026
1 1 1 1 1
1 2 2 2 1
1 2 3 2 1
1 2 2 2 1
1 1 1 1 1
Boundary layer numbers. Distance from edge calculate karo: min(i, j, n-1-i, n-1-j) + 1...
3 views
25 Jan 2026
* *
* *
* *
* *
*
* *
* *
* *
* *
Main diagonal and anti-diagonal stars. Condition: i==j OR i+j==n-1
...
6 views
25 Jan 2026
* *
* *
* *
* *
*
* *
* *
* *
* *
Diagonal lines alternate directions. Row-column relationship formula....
6 views
25 Jan 2026
*********
*******
*****
***
*
***
*****
*******
*********
Inverted triangle, then normal triangle. Coordination of spaces and stars...
8 views
25 Jan 2026
1 2 3 4
12 13 14 5
11 16 15 6
10 9 8 7
Fill the numbers in the matrix in spiral order. Change direction at the boundaries....
6 views
25 Jan 2026
A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
ABCDCBA
ABCBA
ABA
A
Characters increment then decrement. Combine upper and lower pyramid....
7 views
25 Jan 2026
* *
** **
*** ***
********
*** ***
** **
* * Logic: Upper half and lower half symmetric. Carefully calculate the pattern of stars and spaces....
8 views
25 Jan 2026
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15 Consecutive numbers. Maintain the counter and continuously increase it....
8 views
25 Jan 2026
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1 Binomial coefficients. Calculate from previous row to next row: C[i][j] = C[i-1][j-1] + C[i-1][j]...
7 views
24 Jan 2026
1
121
12321
1234321
123454321 Logic: Spaces, increasing numbers, then decreasing. Symmetry should be maintained....
10 views
24 Jan 2026
*
* *
* *
* *
* *
* *
*
Stars only on the boundaries, spaces in between. Combine the upper and lower triangles....
2 views
24 Jan 2026
Maintain a global error log. Log each error to a file with a timestamp. Combine printf(sderror) and file writing....
3 views
24 Jan 2026
Create a program that loads data using the primary method. If it fails, create a fallback method. Multiple levels of error handling....
3 views
24 Jan 2026
Make system calls (write file operations) fail deliberately. Print the value of errno and the message from strerror() on each failure. Understand the pattern....
2 views
24 Jan 2026
Create a function that can return different error types: success=0, null_pointer=-1, out_of_bounds=-2, invalid_input=-3. Use enums for readability....
4 views
24 Jan 2026
Verify assemblies in critical functions using assert(). Example: pointer must not be null. Enabled in debug builds, disabled in release builds....
4 views
24 Jan 2026
Create a function that accesses the array. Validate the index parameter - if out of bounds return error, allow valid access....
3 views
24 Jan 2026
Takes positive integer input from the user. If negative or zero is entered, return an error message and retry. Check the return value for invalid input....
4 views
24 Jan 2026
Allocate memory with malloc(). If NULL is returned (allocation failed) to handle the error, clean the memory that has already been allocated. Resource cleanup....
3 views
24 Jan 2026
Open the file. If null is returned, check errno and print the specific error message (file not found, permission denied, etc.). perror() does that....
4 views
24 Jan 2026
Create a function that performs division but first checks for zero. If the denominator is zero, return an error code and do not write a value to the result pointer....
1 views
24 Jan 2026
Remove duplicate characters from a string. Each character must appear only once in the resulting string. Maintain order....
3 views
24 Jan 2026
Count the frequency of each character in the string. Create an array of size 256 (his). Then print only the non-zero frequencies....
2 views
24 Jan 2026
Append source to destination string. But check for buffer overflow first. Safe implementation of alert()....
2 views
24 Jan 2026
Perform a substring search in a string. Implement strstr() without manually doing it. Count matching characters and return them....
4 views
24 Jan 2026
strcpy() without using - copying character by character from source to destination including null terminator. Use pointer arithmetic....
2 views
24 Jan 2026
Count how many words are in a sentence. Separate words with a space. Handle multiple spaces. Ignore leading/trailing spaces....
3 views
24 Jan 2026
Count the vowels (a, i, i, o, u) in the string. Case-insensitively. Also keep a separate count of each vowel. You can create a histogram.
...
3 views
24 Jan 2026
Check if a string is a palindrome. Case-insensitive and ignore spaces. Example: "a man a plan a canal Panama" is a valid palindrome....
3 views
24 Jan 2026
Reverse a string without extra arrays. Two pointer technique: swap characters from the start and end until they meet in the middle....
2 views
24 Jan 2026
Calculate the length of the string without calling stop(). Count up to the null character in a loop. Understanding the logic is important.
...
4 views
24 Jan 2026
do-while loop by showing menu (1.Add, 2.Subtract, 3.Exit). Take choice input and perform operation. At the exit the loop breaks. Benefit of at-least-once execution....
4 views
24 Jan 2026
Create a simple loop that adds 100 numbers. Then unroll them - 4 operations per iteration. Performance should theoretically be better....
3 views
24 Jan 2026
Print 10x10 multiplication table from nested loop properly formatted. Columns remain aligned. Outer loop rows, inner loop columns....
2 views
24 Jan 2026
Create infinite loop by using while(1). Check other conditions and exit with break on specific condition. Example of multiple exit points....
3 views
24 Jan 2026
Print Fibonacci series of n terms using loop (not recursion). Do variables maintaining same as for previous two numbers. Space-efficient approach....
4 views
24 Jan 2026
There are numbers in the Array. Loop in:
Break at negative number (stop completely)
Zero on continue (skip current iteration)
Demonstrate the effect of both by printing positive numbers.
...
4 views
24 Jan 2026
Print Armstrong numbers from 1 to 1000 (153 = 1³+5³+3³). Nested logic: extract outer loop numbers, inner loop digits and calculate power....
3 views
24 Jan 2026
Two 2D arrays (matrices) input. Multiply with nested loops. Logic: result[i][j] = sum of (a[i][k] * b[k][j]). Complex example of triple nested loop.
...
3 views
24 Jan 2026
Print all the prime numbers in the given range. Outer loop iterate numbers, inner loop divisibility check. Optimization: √n ...
3 views
24 Jan 2026
Take row input from the user. Print a pattern using nested loops that increment the number of stars in each row. Then modify it to decrement it. Mastery of loop control....
5 views
24 Jan 2026
Create a binary tree node (data, left pointer, right pointer). Manually create a tree of 7 nodes and traverse it (inorder, preorder, postorder)....
5 views
24 Jan 2026
Structure with 5 different status flags stored (isActive, isPaid, isVerified, etc.) using bit-fields. Memory saving calculated using vs normal approach....
5 views
24 Jan 2026
Create an array of student structures. Create a sorting function that sorts based on marks. Implement bubble sort with structure swapping....
5 views
24 Jan 2026
Create book structure (title, author structure (name, country), year, price). Create array of books and implement search function by author name....
4 views
24 Jan 2026
Create a structure and union the same members. Do sizeof(). In the union, set one member and read the other - what do you get and why?...
4 views
24 Jan 2026
Create structure of employee (id, name, basic_salary, allowances). Create a function calculateNetSalary() which will calculate the final salary by applying deductions (PF, tax)....
5 views
24 Jan 2026
Create Node structure (data, next pointer). Create Functions: insertAtBeginning(), insertAtEnd(), insertAtPosition(), display(). Proper pointer manipulation....
4 views
24 Jan 2026
Create a date structure (day, month, year). Input two dates and decide which one is first. Handle edge cases: leap year, invalid dates, odd dates...
7 views
24 Jan 2026
Create a structure with char, int, char, or double members. Use sizeof() to find the total size. Then calculate it manually, taking into account padding. Why does the compiler add padding?...
6 views
24 Jan 2026
Make the structure of the student (roll_no, name, marks). Create an array of 5 students. Create Functions: addStudent(), displayAll(), findTopScorer(), calculateClassAverage(). Poor mini-project....
5 views
24 Jan 2026
Write the expression: q = (a = 5, b = 10, a + b);. What is the value of q? Explain the evaluation sequence of the comma operator....
3 views
24 Jan 2026
Test the modulo operator with negative numbers. What result will -7 % 3 give? What difference can there be between different couplings?...
7 views
24 Jan 2026
Left shift the number and multiply it by 2. Neither ...
4 views
24 Jan 2026
Count the number of 1 bits in an integer using bitwise operators. Use the & operator in a loop and right shift it....
8 views
24 Jan 2026
Write the expression: (a > 0) && (++b > 5). If a = 0, will b be incremented or not? Verify by testing short-circuit evaluation....
5 views
24 Jan 2026
By assigning grade with nested ternary operators (90+=A, 80+=B, etc). Then write the same logic if-else. Readability compare....
3 views
24 Jan 2026
Write the expression: a = 5, b = 10, c = 15; result = a + b * c / 5 - 2 % 3; calculate manually, following operator precedence. Then verify with the program....
3 views
24 Jan 2026
Swap two numbers using the SOR operator. Show step-by-step how the values are exchanged. Provide a mathematical proof...
4 views
24 Jan 2026
Check if a number is a power of 2 or not using only bitwise operators. (Hint: n & (n-1) == 0). Explain the logic....
2 views
24 Jan 2026
8 boolean flags can be stored in a single char variable using bitwise operators. Create Functions: setFlag(), clearFlag(), toggleFlag(), checkFlag()....
3 views
24 Jan 2026
Return the address of the local variable in the function. Initialize it in the function. What's the problem? Then indicate the correct reason (dynamic allocation or static variable)....
3 views
24 Jan 2026
Create array of different math functions (add, sub, mul, div) using function pointers. Make a call by selecting from the index. Menu-driven calculator....
2 views
24 Jan 2026
Show the difference between an array and a pointer. The sizeof() operator, the increment operation, and assignment. Which operation is valid where?...
2 views
24 Jan 2026
Create a node structure (data, next pointer). Manually create and link five nodes. Then traverse through the pointers and print them. The foundation of a linked list....
3 views
24 Jan 2026
Create a generic swap function that accepts void pointers and can swap any datatype. Also take a size parameter. Use memcpy.
...
3 views
24 Jan 2026
Create an array of pointers pointing to different strings. Sort the strings without moving the strings - just reorder the pointers....
4 views
24 Jan 2026
Take rows and columns input from the user. Allocate the second array using malloc. Fill in the values, print them, then free the property. There should be no memory leaks....
3 views
24 Jan 2026
Reverse the string using two pointers (start and end). In-place modification without extra array. Logic of character swapping....
4 views
23 Jan 2026
Create an array and traverse it using pointers without bracket notation. Using only pointer increment/decrement. Both forward and backward directions...
2 views
23 Jan 2026
Create an integer variable. Create a pointer to it. Then create a pointer-to-pointer. Then create a triple pointer. Access and modify the original value from each level of the chain.
...
4 views
23 Jan 2026
Create a function like printf that returns the sum of a variable number of integers. The first parameter will be the count, the rest will be numbers. Do that....
3 views
23 Jan 2026
Create a function that generates the Fibonacci sequence. Store the previous two values in static variables. Return the next Fibonacci number on every call....
2 views
23 Jan 2026
Use WITHOUT loop recursively to reverse the string. Clearly define base case and recursive case. Compare with Iterative approach....
6 views
23 Jan 2026
Create a generic function to sort the array that accepts a comparison function as a callback. Implement both ascending and descending using different callbacks....
4 views
23 Jan 2026
Create char array of functions: add, subtract, multiply, divide. Take operator input from the user and call the corresponding function pointer. Dynamic function selection demo....
2 views
23 Jan 2026
By passing an array to the function. Calculate Function: sum, average, min, max, range. Return values simultaneously using pointers (multiple output parameters)....
4 views
23 Jan 2026
Calculate factorials using three methods: root-recursive, recursive, and tail-recursive. Examine the efficiency of each method for large numbers....
3 views
23 Jan 2026
Create two functions - swapByValue() and swapByReference(). In main, test both on the same numbers. Explain why the first won't work and why the second will....
5 views
23 Jan 2026
Create a function isPrime() to check the number. Create another function printPrimesInRange() to print all the primes in the range using isPrime(). Example of modular code....
2 views
23 Jan 2026
Create a recursive function to calculate x^n. If n is negative, return 1/x^|n|. If n=0, return 1. Track the depth of the recursion....
5 views
23 Jan 2026
Create a union containing an int, float, or char array. Store a value in one member, then read it from the other. What value will be returned, and why (concept of memory overlap)?...
5 views
23 Jan 2026
Const int, const pointer, pointer to const - declare all three. Then try modifying them and see which modification is allowed and which one gives a compile error....
4 views
23 Jan 2026
Use a normal variable and a register variable in a loop. Increment both by 1 million. Measure the time difference (practical experiment).
...
4 views
23 Jan 2026
Create a global variable 'count' with the value 10. Create a local variable 'count' in the function with the value 5. Show the difference by printing both values inside and outside the function....
4 views
23 Jan 2026
Make a list of 7 days of the week. Input the number (0-6) from the user and print the corresponding day name. Error message on invalid number. Show the internally integer values of the enum....
4 views
23 Jan 2026
Cast the float value 9.7 to a float in different ways: implicit, explicit, using floor, using cel. What will be the result in each case and why?...
4 views
23 Jan 2026
By printing the size of different datatypes (char, int, float, double, long, pointers). Then create array of each type and verify that array size = element_count * sizeof(type)....
4 views
23 Jan 2026
Create nested blocks (outer, middle, inner). Use the same variable name 'x' in all three. Print the value at each level and understand which value is coming from which scope....
5 views
23 Jan 2026
Create a function that counts the number of times it has been called on each call. Implement it using a static variable. Call main 10 times and display the count....
4 views
23 Jan 2026
Two integers need to be swapped without using a third variable. Use three different methods: arithmetic, XOR, and one more trick. Explain the logic behind each method....
3 views
23 Jan 2026
Take a decimal number from the user (validation: positive integer only). Then convert it to binary and print it, also showing the step-by-step conversion process....
4 views
23 Jan 2026
As soon as the program starts, check whether the input is coming from a file (redirected) or from the keyboard. If it is from a file, then give a "Reading from file..." message, otherwise give an "Ent...
4 views
23 Jan 2026
Input multiple records (name and age) in a loop. After each entry ask "Add more? (y/n)". Validate input - name must not be blank, age must be between 1-120....
3 views
23 Jan 2026
Have the user input a password (it should not be visible on the screen). Then check: minimum 8 characters, at least 1 digit, and 1 uppercase letter. Report the result and provide suggestions if applic...
4 views
23 Jan 2026
Take temperature and unit (C/F) input from user. Handle case-insensitive (c, C, f, F). If invalid unit is there then show error and re-input mango. Convert and show result upto 2 decimal places....
3 views
23 Jan 2026
By printing student data (name, roll no, marks) in table format where columns are properly aligned. Names should be left-aligned, numbers right-aligned, and proper spacing maintained....
2 views
23 Jan 2026
Take number input from the user until they enter -999. Check each input to see if it is an integer. If a float is entered, give a warning and ignore the decimal part....
3 views
23 Jan 2026
Show the user a menu (1-5 options). If they enter anything other than a number (character, symbol), detect scanf fail, clear the buffer, and try to input mango again....
2 views
23 Jan 2026
Input marks for 5 subjects. If any mark is less than 0 or more than 100, input that subject again. Calculate the total and percentage only after all marks are valid....
4 views
23 Jan 2026
Input two numbers and one operator (+, -, *, /) from the user. If the operator is invalid or division by zero then give a proper error message and input the operator again. Program should run until th...
28 views
23 Jan 2026
Count subarrays whose sum is an even number - How do you provide the mathematical logic to count combinations by tracking the parity (odd/even) of the prefix sum?...
5 views
23 Jan 2026
Finding the maximum difference of RR[j] - RR[i] where j > i - logic to update the max difference while tracking the minimum element?...
9 views
23 Jan 2026
Find equilibrium index in array where left sum = right sum - Approach to detect balance point by maintaining running sum?...
4 views
23 Jan 2026
Find the smallest subarray whose sum is greater than or equal to the given value - Two pointer sliding window expansion/shrink decision logic?...
2 views
23 Jan 2026
Inversion counting in an array (how many times the larger element comes before the smaller one) - logic for counting integrals using merge sort modification?...
4 views
23 Jan 2026
Find the longest subarray whose sum is equal to a - Mechanism to find matching sums by prefix sum and hashmap it?...
2 views
23 Jan 2026
Trapping Rainwater Problem - Logic to calculate water level at each position while maintaining left max and right max?...
3 views
23 Jan 2026
Calculate minimum swaps to sort an array - mathematical approach to cycle detection and swap counting?...
4 views
23 Jan 2026
Finding majority element in array that appears no/more than 2 times - How does the logic of count increment/decrement work while maintaining candidates?...
4 views
23 Jan 2026
Find the subarray whose sum is maximum (Kadne's logic) - What is the intuition for resetting when the current sum is negative and why?...
4 views
23 Jan 2026
Finding leader elements in an array (those greater than the subelements on their right side) - what is the logic behind scanning from right to left?...
5 views
23 Jan 2026
Tracking the maximum element in a sliding window of size k - Efficient approach to updating the max as the window slides?...
5 views
23 Jan 2026
The array is to be arranged in a zig-zag pattern: small-large-small-large - condition to swap adjacent elements by adding them?...
5 views
23 Jan 2026
Finding packs in array (element greater than both of its neighbors) - different logic for boundary conditions and middle elements?...
3 views
23 Jan 2026
Merging two sorted arrays into a third sorted array - two pointer approach followed by comparison and selection logic?...
4 views
23 Jan 2026
The array contains product precedences, you need to apply a discount: 10% on the first 5 items, 5% on the rest - how do you handle the conditional discount logic?...
4 views
23 Jan 2026
It's a binary array (0 and 1), you need to find the length of the maximum consecutive 1s - when will the counter reset logic be applied?...
3 views
23 Jan 2026
How to access next element in circular array with wraparound - modelo operator trick of index calculation by doing that?...
3 views
23 Jan 2026
The array needs to be divided into two equal parts such that the sums of both parts are almost equal - what would be the strategy to find the partition point?...
3 views
23 Jan 2026
Array contains numbers, you need to find the difference of adjacent elements and store it in a new array - how will you implement the pattern RR[i+1] - RR[i]?...
4 views
23 Jan 2026
An array containing distances stored in kilometers, needs to convert them all to miles (1 km = 0.621 miles) - systematic way to apply the formula?...
2 views
23 Jan 2026
There is rainfall data of 30 days in array, find out on which day maximum rainfall occurred and what was that value-logic of tracking both maximum value and index?...
4 views
23 Jan 2026
I want to divide the array into two parts - the first half containing even numbers and the second half containing odd numbers - how do I approach the partitioning logic?...
3 views
23 Jan 2026
There is an array of lottery numbers and the user entered his number, check whether he won or not - how will you implement the basic logic of linear search?...
5 views
23 Jan 2026
The array contains a number of items, the user needs to specify a budget and check how many items they can afford - the logic to maintain a running shoe?...
12 views
23 Jan 2026
There are some numbers in an array and you need to find out whether all the numbers are same or different - how do you design comparison logic from the first element?...
10 views
21 Jan 2026
Suppose a student has entered the marks for their six subjects into an array. What will happen if they accidentally enter the marks for a seventh subject as well? Will the program crash, or something ...
5 views
21 Jan 2026
When initializing an array, if I write `int arr[5] = {10, 20, 30}`, what values will be stored in the remaining two elements, and how does the compiler handle this?...
4 views
21 Jan 2026
If I want to store the salaries of 100 employees in my program, should I create 100 separate variables or use an array? What problems might arise with each approach?...
3 views
21 Jan 2026
When we declare an array in C language, such as int numbers[10],
how exactly is it stored in memory, and how does each element get its memory address?...