Logic-Building Assignments in C Language
No. Problem Statement & Expected Output
1 Write a program to check whether a given number is even or odd.
Input: 7 ? Output: Odd
2 Find the largest among three numbers.
Input: 10, 20, 15 ? Output: 20
3 Check if a number is prime.
Input: 17 ? Output: Prime
4 Find factorial of a number using loop.
Input: 5 ? Output: 120
5 Find factorial of a number using recursion.
Input: 4 ? Output: 24
6 Print Fibonacci series up to n terms.
Input: 6 ? Output: 0 1 1 2 3 5
7 Check if a number is palindrome.
Input: 121 ? Output: Palindrome
8 Check if a number is Armstrong number.
Input: 153 ? Output: Armstrong
9 Find the sum of digits of a number.
Input: 987 ? Output: 24
10 Reverse a given number.
Input: 456 ? Output: 654
11 Swap two numbers using a temporary variable.
Input: a=2, b=3 ? Output: a=3, b=2
12 Swap two numbers without using a temporary variable.
Input: a=4, b=7 ? Output: a=7, b=4
13 Find GCD of two numbers.
Input: 12, 18 ? Output: 6
14 Find LCM of two numbers.
Input: 4, 5 ? Output: 20
15 Print sum of first N natural numbers.
Input: 10 ? Output: 55
16 Check if a year is leap year or not.
Input: 2024 ? Output: Leap Year
17 Print multiplication table of a number.
Input: 5 ? Output: 5�1=5 ? 5�10=50
18 Count number of digits in a number.
Input: 1234 ? Output: 4
19 Convert Celsius to Fahrenheit.
Input: 0 ? Output: 32�F
20 Convert binary number to decimal.
Input: 1011 ? Output: 11
21 Convert decimal to binary.
Input: 7 ? Output: 111
22 Reverse a string without using strrev().
Input: "hello" ? Output: "olleh"
23 Count vowels and consonants in a string.
Input: "Apple" ? Output: 2 vowels, 3 consonants
24 Find length of a string manually.
Input: "Code" ? Output: 4
25 Copy string without using strcpy().
Input: "Hello" ? Output: Copied string: "Hello"
26 Compare two strings without strcmp().
Input: "abc", "abc" ? Output: Equal
27 Concatenate two strings.
Input: "Hello", "World" ? Output: "HelloWorld"
28 Check if a string is palindrome.
Input: "madam" ? Output: Palindrome
29 Count spaces, digits, and alphabets in string.
Input: "Hi 123" ? Output: Alphabets=2, Digits=3, Spaces=1
30 Find sum of array elements.
Input: [1,2,3,4,5] ? Output: 15
31 Find max element in array.
Input: [10,20,15] ? Output: 20
32 Find min element in array.
Input: [3,7,1,9] ? Output: 1
33 Sort array in ascending order.
Input: [5,2,8] ? Output: [2,5,8]
34 Find second largest element.
Input: [12,45,23,51] ? Output: 45
35 Search an element in array (linear search).
Input: 5, [1,2,3,5,6] ? Output: Found
36 Perform binary search.
Input: [1,2,3,4,5], key=4 ? Output: Found at index 3
37 Merge two arrays.
Input: [1,2], [3,4] ? Output: [1,2,3,4]
38 Reverse array elements.
Input: [1,2,3] ? Output: [3,2,1]
39 Pointer program to swap two numbers.
Input: a=10,b=20 ? Output: a=20,b=10
40 Demonstrate call by value and call by reference.
Output: Shows difference in swapping result
41 Print address of a variable using pointer.
Input: int x=5 ? Output: Address=0x...
42 Pointer to array example.
Output: Prints elements using pointer arithmetic
43 Function returning pointer.
Output: Prints pointer returned by function
44 Find sum using pointer.
Input: 10,20 ? Output: 30
45 Simple calculator using switch case.
Input: 2+3 ? Output: 5
46 Count even and odd numbers in array.
Input: [1,2,3,4] ? Output: Even=2, Odd=2
47 Display ASCII value of a character.
Input: A ? Output: 65
48 Convert lowercase to uppercase.
Input: a ? Output: A
49 Find power of a number.
Input: 2^3 ? Output: 8
50 Find simple interest.
Input: P=1000,R=5,T=2 ? Output: 100
51 Calculate compound interest.
Input: P=1000,R=10,T=2 ? Output: 210
52 Check number positive/negative.
Input: -5 ? Output: Negative
53 Check alphabet, digit or special character.
Input: '@' ? Output: Special character
54 Print pattern of stars (triangle).
Input: 3 ? Output: *, **, ***
55 Print pyramid pattern.
Output: 3 levels pyramid
56 Print inverted pyramid.
Output: 3 rows inverted
57 Print Floyd's triangle.
Output: 1 2 3 / 4 5 6 etc.
58 Print Pascal's triangle.
Output: Pattern of binomial coefficients
59 Sum of diagonal elements in matrix.
Input: 3�3 matrix ? Output: Sum=...
60 Transpose of matrix.
Input: 2�2 ? Output: Transposed
61 Add two matrices.
Output: Result matrix
62 Multiply two matrices.
Output: Resultant product
63 Calculate determinant of 2�2 matrix.
Output: ad?bc
64 Check symmetric matrix.
Output: Symmetric/Not
65 Find frequency of each character in string.
Input: "hello" ? Output: h=1,e=1,l=2,o=1
66 Count words in string.
Input: "I love C" ? Output: 3
67 Remove spaces from string.
Input: "I am coder" ? Output: "Iamcoder"
68 Replace vowels by '*'.
Input: "apple" ? Output: "*ppl*"
69 Reverse words in a sentence.
Input: "I am KD" ? Output: "KD am I"
70 Print ASCII table from A-Z.
Output: 65-90
71 Find area of circle using function.
Input: r=5 ? Output: 78.5
72 Structure for student marks.
Output: Name, Roll, Marks
73 Structure array of students.
Output: Displays list
74 Nested structure example.
Output: Shows nested member access
75 File handling: write data to file.
Output: file.txt created
76 File handling: read file.
Output: Displays file content
77 Count lines in file.
Output: Line count
78 Count words in file.
Output: Word count
79 Append content to file.
Output: File updated
80 Copy file content to another file.
Output: target.txt created
81 Dynamic memory allocation (malloc).
Output: Allocated memory and printed values
82 Realloc usage example.
Output: Reallocated memory
83 Free() usage.
Output: Memory freed
84 Enum example.
Output: Enumeration values
85 Union vs structure difference.
Output: Demonstrated
86 Pointer to structure.
Output: Accessed structure via pointer
87 Array of structure.
Output: Printed records
88 Nested loops pattern printing.
Output: Diamond pattern
89 Print prime numbers between 1-100.
Output: List of primes
90 Find average of n numbers.
Output: Average=?
91 Generate random number.
Output: Random value
92 Use of typedef.
Output: Custom alias created
93 Pointer to function example.
Output: Called via pointer
94 Recursion example: sum of digits.
Output: Calculated
95 Recursion example: reverse number.
Output: Reversed
96 Find factorial using pointer.
Output: 120
97 Convert string to integer (atoi logic).
Input: "123" ? Output: 123
98 Convert integer to string (itoa logic).
Input: 123 ? Output: "123"
99 Print pattern of numbers (1 12 123...).
Input: 3 ? Output: pattern
100 Mini project: Menu-driven program (Calculator, Prime check, etc.).
Output: Multiple options
Logic-Building Questions in C++ Language Includes AWT + OOP + Core Logic.
No. Problem Statement Expected Output
1 Write a program to print "Hello, C++ World".
Output: Hello, C++ World
2 Find the sum of two numbers using class and object.
Input: 10, 20 ? Output: 30
3 Demonstrate use of constructor and destructor.
Output: Constructor called, Destructor called
4 Create a class to find the area of a rectangle.
Input: l=5,b=4 ? Output: 20
5 Create a class to check whether a number is even or odd.
Input: 9 ? Output: Odd
6 Create a class to find factorial of a number using function inside class.
Input: 5 ? Output: 120
7 Demonstrate function overloading.
Output: Displays results of overloaded functions
8 Demonstrate operator overloading for '+' operator.
Input: Two complex numbers ? Output: Sum
9 Implement friend function to access private data.
Output: Accessed private value
10 Demonstrate inheritance (single level).
Output: Base and Derived class values
11 Demonstrate multilevel inheritance.
Output: Data of grandparent, parent, child
12 Demonstrate multiple inheritance.
Output: Values from both base classes
13 Implement hybrid inheritance.
Output: Combined data
14 Use virtual base class to remove ambiguity.
Output: Correct data from base class
15 Demonstrate constructor overloading.
Output: Constructors with different arguments called
16 Create a copy constructor example.
Output: Copy successful
17 Create a program using static member function.
Output: Static function executed
18 Demonstrate use of this pointer.
Output: Displays current object address
19 Demonstrate polymorphism using virtual function.
Output: Derived class function executed
20 Demonstrate pure virtual function (abstract class).
Output: Implemented in derived class
21 Program to find factorial using recursion.
Input: 4 ? Output: 24
22 Program to check palindrome number.
Input: 121 ? Output: Palindrome
23 Program to find Fibonacci series using recursion.
Input: 5 ? Output: 0 1 1 2 3
24 Reverse a string using inbuilt function.
Input: "hello" ? Output: "olleh"
25 Sort array using STL sort().
Input: [5,2,9] ? Output: [2,5,9]
26 Find maximum using STL max_element().
Input: [3,7,1] ? Output: 7
27 Find frequency of each element using map.
Input: [1,2,2,3] ? Output: 1:1, 2:2, 3:1
28 Use of vector container.
Output: Elements displayed
29 Use of list container.
Output: List elements printed
30 Use of set to store unique elements.
Input: [2,2,3,4] ? Output: [2,3,4]
31 Use of multiset to allow duplicates.
Output: Shows all elements
32 Use of map (key-value).
Output: Key=Roll, Value=Marks
33 Use of queue STL.
Output: FIFO order
34 Use of stack STL.
Output: LIFO order
35 Reverse a string using stack STL.
Input: "abc" ? Output: "cba"
36 Demonstrate exception handling (divide by zero).
Output: Caught divide by zero
37 Use try-catch-finally equivalent.
Output: Exception handled
38 Create a template function to swap values.
Input: 2,3 ? Output: 3,2
39 Template class for addition.
Output: Works for int, float
40 Demonstrate file handling (read/write).
Output: File created
41 Append data to file using fstream.
Output: Updated file
42 Count words in a text file.
Output: Word count
43 Create student class and store data in file.
Output: Student.txt created
44 Display contents of file line by line.
Output: File data printed
45 Program to check prime number.
Input: 7 ? Output: Prime
46 Reverse an integer.
Input: 456 ? Output: 654
47 Check Armstrong number.
Input: 153 ? Output: Armstrong
48 Find LCM of two numbers.
Input: 4,5 ? Output: 20
49 Find GCD of two numbers.
Input: 8,12 ? Output: 4
50 Count vowels in string.
Input: "hello" ? Output: 2
51 Count words in a sentence.
Input: "I love coding" ? Output: 3
52 Remove spaces from string.
Input: "I am" ? Output: "Iam"
53 Convert string to uppercase.
Input: "abc" ? Output: "ABC"
54 Reverse array elements.
Input: [1,2,3] ? Output: [3,2,1]
55 Find sum of array using pointer.
Output: Sum=...
56 Pointer to class example.
Output: Accessed via pointer
57 Dynamic memory allocation using new/delete.
Output: Values assigned
58 Demonstrate deep copy vs shallow copy.
Output: Deep copy successful
59 Demonstrate encapsulation.
Output: Private members accessed via methods
60 Demonstrate data hiding.
Output: Access denied to private
61 Use inline function.
Output: Executed inline
62 Program to overload insertion (<<) operator.
Output: Displays object data
63 Program to overload extraction (>>) operator.
Output: Takes input easily
64 Use of namespace.
Output: Displays data from namespace
65 Demonstrate friend class.
Output: Access given
66 Display ASCII value of characters.
Input: A ? Output: 65
67 Pattern printing (triangle).
Input: 3 ? Output: pattern
68 Pyramid pattern.
Output: star pyramid
69 Inverted pyramid.
Output: inverted pattern
70 Floyd triangle.
Output: 1, 2 3, 4 5 6
71 Use of recursion for sum of digits.
Output: 6
72 Use of array of objects.
Output: Multiple students displayed
73 Use of static data member.
Output: Count of objects
74 Demonstrate hybrid inheritance.
Output: Displays hierarchy
75 Demonstrate multiple catch blocks.
Output: Exception handled
76 Demonstrate constructor in derived class.
Output: Constructors called sequence
77 Program to implement banking system (class).
Output: Balance, deposit, withdraw
78 Program to implement simple calculator (OOP).
Output: Result
79 Program to demonstrate function overriding.
Output: Derived class overrides base
80 Find transpose of matrix.
Output: Transposed matrix
81 Add two matrices.
Output: Sum matrix
82 Multiply two matrices.
Output: Product matrix
83 Check symmetric matrix.
Output: Yes/No
84 Create linked list using class.
Output: List created
85 Implement stack using class.
Output: Push, Pop
86 Implement queue using class.
Output: Enqueue, Dequeue
87 Demonstrate file pointer usage.
Output: Cursor position shown
88 Program for student grade system.
Output: A/B/C grade
89 Find factorial using pointer.
Output: 120
90 Use of const member function.
Output: Safe access
91 Program using default arguments.
Output: Works with missing params
92 Demonstrate inline class function.
Output: Executed inline
93 Convert binary to decimal.
Output: 11
94 Convert decimal to binary.
Output: 1010
95 Count objects created.
Output: 5 objects created
96 Demonstrate virtual destructor.
Output: Called correctly
97 Use of function template for max value.
Output: Works for all types
98 Program to print diamond pattern.
Output: Diamond
99 Demonstrate composition and aggregation.
Output: Shows relationship
100 Mini OOP project - Employee Payroll using classes.
Output: Full report
Logic-Building Questions in JAVA Language Includes AWT + OOP + Core Logic.
h
No. Problem Statement Expected Output
1 Print "Hello Java".
Output: Hello Java
2 Sum of two numbers.
Output: 30
3 Check even or odd.
Input: 5 ? Output: Odd
4 Factorial of a number.
Input: 5 ? Output: 120
5 Fibonacci series.
Input: 5 ? Output: 0 1 1 2 3
6 Prime number check.
Input: 11 ? Output: Prime
7 Palindrome number.
Input: 121 ? Output: Palindrome
8 Armstrong number.
Input: 153 ? Output: Armstrong
9 Reverse string.
Input: "java" ? Output: "avaj"
10 Count vowels in string.
Input: "Hello" ? Output: 2
11 Convert string to uppercase.
Input: "hello" ? Output: "HELLO"
12 Compare two strings.
Input: "abc","abc" ? Output: Equal
13 Check leap year.
Input: 2024 ? Output: Leap Year
14 Swap numbers.
Output: swapped
15 Find largest among three numbers.
Output: Largest=...
16 Array sum.
Output: 15
17 Find second largest.
Output: 45
18 Sort array.
Output: Sorted
19 Linear search.
Output: Found
20 Binary search.
Output: Found
21 Reverse array.
Output: reversed
22 Count digits.
Output: count
23 Sum of digits.
Output: 6
24 Matrix addition.
Output: Result matrix
25 Transpose of matrix.
Output: Transposed
26 OOP: class & object example.
Output: Object created
27 Constructor demo.
Output: Constructor called
28 Method overloading.
Output: Different methods called
29 Method overriding.
Output: Derived method executed
30 Inheritance example.
Output: Parent+Child data
31 Multilevel inheritance.
Output: Data hierarchy shown
32 Abstract class demo.
Output: Implemented method
33 Interface demo.
Output: Interface implemented
34 Package demo.
Output: Package imported
35 Exception handling demo.
Output: Exception caught
36 Multiple catch demo.
Output: Caught
37 Finally block demo.
Output: Always executes
38 Try with resources demo.
Output: Auto closed
39 Static method demo.
Output: Static executed
40 Final variable demo.
Output: Constant value
41 StringBuilder reverse demo.
Output: reversed
42 AWT: Create Frame window.
Output: Frame opened
43 Add Button to Frame.
Output: Button visible
44 Add Label to Frame.
Output: Label shown
45 Add TextField to Frame.
Output: Input field visible
46 Add Checkbox to Frame.
Output: Checkbox visible
47 Add Choice list.
Output: Dropdown visible
48 Add List component.
Output: List visible
49 Add TextArea.
Output: Text area visible
50 Handle Button click event.
Output: Message printed
51 Handle Key event.
Output: Key detected
52 Handle Mouse event.
Output: Click detected
53 BorderLayout demo.
Output: 5 regions layout
54 FlowLayout demo.
Output: Left to right layout
55 GridLayout demo.
Output: Grid displayed
56 Create simple calculator in AWT.
Output: Operations performed
57 Create login form in AWT.
Output: Success message
58 Applet life cycle demo.
Output: init, start, stop
59 Thread demo.
Output: Running concurrently
60 Runnable interface demo.
Output: Thread started
61 Sleep method demo.
Output: Paused thread
62 Synchronization demo.
Output: Safe thread access
63 File read demo.
Output: File content
64 File write demo.
Output: File created
65 Serialization demo.
Output: Object serialized
66 Deserialization demo.
Output: Object restored
67 ArrayList demo.
Output: Elements displayed
68 HashMap demo.
Output: Key-value pairs
69 LinkedHashMap demo.
Output: Ordered pairs
70 TreeMap demo.
Output: Sorted keys
71 HashSet demo.
Output: Unique elements
72 LinkedList demo.
Output: List printed
73 Queue demo.
Output: FIFO order
74 Stack demo.
Output: LIFO order
75 Exception handling in file I/O.
Output: File not found handled
76 Pattern printing: triangle.
Output: * pattern
77 Pattern printing: pyramid.
Output: pattern
78 Pattern printing: diamond.
Output: pattern
79 Count words in a string.
Output: 3
80 Count characters in a string.
Output: length
81 Interface for bank interest.
Output: Calculated interest
82 Implement inheritance in banking example.
Output: Balances updated
83 Use of super keyword.
Output: Parent data
84 Use of this keyword.
Output: Current object
85 Use of constructor chaining.
Output: Sequence shown
86 Multiple interface implementation.
Output: All methods executed
87 Nested class demo.
Output: Inner class works
88 Static nested class demo.
Output: Accessed without object
89 Enum demo.
Output: Enum values
90 Math class usage.
Output: sqrt, pow results
91 String split demo.
Output: tokens displayed
92 Regular expression match demo.
Output: Match found
93 Convert binary to decimal.
Output: 11
94 Convert decimal to binary.
Output: 1011
95 Factorial using recursion.
Output: 120
96 Reverse number.
Output: reversed
97 Check alphabet/digit/special.
Output: Alphabet
98 Simple interest calculator.
Output: 100
99 GUI-based prime checker.
Output: Prime
100 Mini AWT Project - Student Registration Form.
Output: GUI form created
Logic-Building Questions in Data Structures (C / C++ / Java)
No. Problem Statement Expected Output
1 Implement array operations (insert, delete, traverse).
Output: Updated array
2 Implement linear search.
Output: Found
3 Implement binary search.
Output: Found
4 Find max/min in array.
Output: values
5 Reverse an array.
Output: reversed
6 Sort array using bubble sort.
Output: sorted
7 Sort array using selection sort.
Output: sorted
8 Sort array using insertion sort.
Output: sorted
9 Sort array using quick sort.
Output: sorted
10 Sort array using merge sort.
Output: sorted
11 Implement stack using array.
Output: Push/Pop
12 Implement stack using linked list.
Output: Stack operations
13 Implement queue using array.
Output: Enqueue/Dequeue
14 Implement circular queue.
Output: circular operations
15 Implement queue using linked list.
Output: operations
16 Implement singly linked list.
Output: Linked list displayed
17 Insert node at beginning in linked list.
Output: updated list
18 Insert node at end in linked list.
Output: updated list
19 Insert node after a position.
Output: updated list
20 Delete node from linked list.
Output: updated list
21 Count nodes in linked list.
Output: count
22 Reverse linked list.
Output: reversed list
23 Search element in linked list.
Output: Found
24 Sort linked list.
Output: sorted
25 Merge two linked lists.
Output: merged
Latest posts by Mahesh Wabale (see all)
- Logic Building Assignments – 2025 - October 15, 2025
- Create Your First Ansible Playbook: Step-by-Step Guide - September 29, 2025
- Ansible Beginner’s Guide – What is Ansible & Step-by-Step IT Automation - September 9, 2025