[go: up one dir, main page]

0% found this document useful (0 votes)
10 views6 pages

C Questions For The Starting

The document outlines a series of programming tasks primarily focused on C language exercises. These tasks include basic operations like swapping variables, finding sums, checking for even/odd numbers, and generating patterns, as well as more complex operations involving arrays, strings, and linked lists. It also includes challenges related to frequency counting, rotation of arrays, and adding two numbers represented by linked lists.

Uploaded by

Vansh Nayak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views6 pages

C Questions For The Starting

The document outlines a series of programming tasks primarily focused on C language exercises. These tasks include basic operations like swapping variables, finding sums, checking for even/odd numbers, and generating patterns, as well as more complex operations involving arrays, strings, and linked lists. It also includes challenges related to frequency counting, rotation of arrays, and adding two numbers represented by linked lists.

Uploaded by

Vansh Nayak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Question

1. Write a program to receive the two numbers in variables, and then swap the values of
variables, with and without using third variable.

2. Write a program to find sum of all integers greater than 100 & less than 200 and are
divisible by 5.
3. Write a C program to print multiplication table of any number (Using For and While
loop).
4. Write a C program to check whether a given number is even or odd (Using 2 or three
method).
5. Write a C program to check whether a given number is positive or negative.
6. Write a C program to find whether a given year is a leap year or not.(Century year also).
7. Write a C program to find the largest of three numbers.
8. Write a C program to check whether an alphabet is a vowel or consonant.
9. Write a program in C to read 10 numbers from keyboard and find their sum and average.
10. Write a program in C to display the pattern like right angle triangle using an asterisk
*
**
***
****
11. Write a program in C to display the pattern like right angle triangle with a number.
The pattern like :

1
12
123
1234
12. Write a program in C to make such a pattern like right angle triangle with a number
which will repeat a number in a row.
The pattern like :
1
22
333
4444
13. Write a program in C to make such a pattern like right angle triangle with number
increased by 1.
The pattern like :
1
23
456
7 8 9 10
14. Write a program in C to make such a pattern like a pyramid with numbers increased by
1.
1
23
456
7 8 9 10
15. Write a program in C to make such a pattern like a pyramid with an asterisk.

*
**
***
****
16. Write a C program to calculate the factorial of a given number.(For large no. also)
17. Write a program in C to print the Floyd's Triangle.
1
01
101
0101
10101
18. Write a c program to check whether a given number is a perfect number or not.
19. Write a C program to check whether a given number is an armstrong number or not.
20. Write a program in C to display the first n terms of Fibonacci series.
21. Write a C program to determine whether a given number is prime or not.
22. Write a program in C to display the number in reverse order.
23. Write a program in C to check whether a number is a palindrome or not.
24. Write a program in C to convert a decimal number into binary without using an array.
25. Write a program in C to print a string in reverse order.
26. Write a C program to find the length of a string without using the library function.
27. Write a program in C to store elements in an array and print it.
28. Write a program in C to read n number of values in an array and display it in reverse
order.
29. Write a program in C to count a total number of duplicate elements in an array.
30. Write a program in C to print all unique elements in an array.
31. Write a program in C to merge two arrays of same size sorted in decending order.
32. Write a program in C to count the frequency of each element of an array.
33. Write a program in C to find the maximum and minimum element in an array.
34. Write a program in C to insert New value in the array (sorted list ).
Test Data :
Input the size of array: 3
Input 3 elements in the array in ascending order:
Element - 0: 5
Element - 1: 7
Element - 2: 9
Input the value to be inserted: 8
Expected Output:
The exist array list is:
579
After Insert the list is:
5789
35. Write a program in C to delete an element at desired position from an array.
36. Write a program in C to find the second largest element in an array.
37. Write a program in C to input a string and print it.
38. Write a program in C to separate the individual characters from a string.
39. Write a program in C to count the total number of words in a string.
40. Write a program in C to find the second smallest element in an array.
41. Write a program in C to find sum of right diagonals of a matrix.
42. Write a program in C to find a pair with given sum in the array.
Expected Output:
The given array: 6 8 4 -5 7 9
The given sum: 15
Pair of elements can make the given sum by the value of index 0 and 5
43. Write a program in C to find the number occurring odd number of times in an array.
44. Write a program in C to find the missing number from a given array. There are no
duplicates in list.
Expected Output:
The given array is: 1 3 4 2 5 6 9 8
The missing number is: 7
45. Write a program in C to find the smallest missing element from a sorted array.
Expected Output:
The given array is: 0 1 3 4 5 6 7 9
The missing smallest element is: 2
46. Write a program in C to find two elements whose sum is closest to zero.
47. Write a program in C to sort an array of 0s, 1s and 2s.
48. Write a program in C to move all zeroes to the end of a given array.
Expected Output:
The given array is: 2 5 7 0 4 0 7 -5 8 0
The new array is:
2 5 7 8 4 -5 7 0 0 0
49. Write a program in C to print all unique elements of an unsorted array.
50. Write a program in C to find a pair with the given difference.
Expected Output:
The given array is:
1 15 39 75 92
The given difference is: 53
The pair are: (39, 92)
51. Write a program in C to rearrange positive and negative numbers alternatively in a
given array.
N.B.: If positive numbers are more they appear at the end and for also negative numbers,
they too appear in the end of the array.
Expected Output:
The given array is:
-4 8 -5 -6 5 -9 7 1 -21 -11 19
The rearranged array is:
-4 7 -5 1 -21 5 -11 8 -9 19 -6
52. Write a program in C to segregate 0s and 1s in an array.
Expected Output:
The given array is:
101001011
The array after segregation is: 0 0 0 0 1 1 1 1 1
53. Write a program in C to segregate even and odd elements on an array.
Expected Output:
The given array is:
17 42 19 7 27 24 30 54 73
The array after segregation is: 54 42 30 24 27 7 19 17 73
54. Write a program in C to rearrange an array in such an order that– smallest, largest, 2nd
smallest, 2nd largest and on.
Expected Output:
The given array is:
581429376
The new array is:
192837465
55. Write a program in C to find minimum number of swaps required to gather all elements
less than or equals to k.
Expected Output:
The given array is:
2795874
The minimum swap required is: 2
56. Write a program in C to swap two numbers using call by reference.
57. Write a program in C to print all permutations of a given string.
58. Write a program in C to find the length of a string without using library function.
59. Write a program in C to print individual characters of string in reverse order.
60. Write a program in C to find maximum occurring character in a string.
Test Data:
Input the string: Welcome to m programming
Expected Output:
The Highest frequency of character 'm'
Appears number of times: 4
61. Write a C program to sort a string array in ascending order.
62. Write a C program to check whether a given substring is present in the given string.
63. Write a program in C to read a sentence and replace lowercase characters by uppercase
and vice-versa.
64. Write a program in C to find the number of times a given word 'the' appears in the given
string.
Test Data:
Input the string: The string where the word the present more than once.
Expected Output:
The frequency of the word 'the' is: 3
65. Write a program in C to Find the Frequency of Characters.
Test Data:
Input the string: This is a test string
Input the character to find frequency: i
Expected Output:
The frequency of 'i' is: 3
66. Write a program in C to Concatenate Two Strings Manually.
67. Write a program in C to find the largest and smallest word in a string.
68. Write a program in C to read a file and remove the spaces between two words of its
content.
69. Write a program in C to replace the spaces of a string with a specific character.
70. Write a program in C to create and display Singly Linked List.
71. Write a program in C to create a singly linked list of n nodes and count the number of
nodes.
72. Write a program in C to insert a new node at the beginning of a Singly Linked List.
73. Write a program in C to insert a new node at the end of a Singly Linked List.
74. Write a program in C to insert a new node at the middle of Singly Linked List.
75. Write a program in C to delete first node of Singly Linked List.
76. Write a program in C to delete the last node of Singly Linked List.
77. Write a program in C to delete a node from the middle of Singly Linked List.
78. Write a program in C to create a singly linked list of n nodes and display it in reverse
order.
79. Write a program in C to swap two numbers using function.
80. Write a C program how to implement stack using Queue?
81. Write a C program how to implement Queue using Stack?
82. Given a linked list of N nodes. The task is to check if the the linked list has a loop.
83. Given a linked list consisting of L nodes and given a number N. The task is to find the
Nth node from the end of the linked list.

Must Do Coding Questions


A. Given an ArrayList of N lowercase characters. The task is to count frequency of elements in
the list.
Input Format:
First line of testcase contains T, number of testcases. For each testcase, first line contains
number of queries Q. Each query may be any one of the two type:
1. "i" with "c" : insert the element "c" into the ArrayList
2. "f" with "c": find the frequency of "c" in the ArrayList.
B. Given an unsorted array arr[] of size N, rotate it by D elements (clockwise).
Input:
The first line of the input contains T denoting the number of testcases. First line of eacg test
case contains two space separated elements, N denoting the size of the array and an integer D
denoting the number size of the rotation. Subsequent line will be the N space separated array
elements.
Explanation:
Testcase 1: 1 2 3 4 5 when rotated by 2 elements, it becomes 3 4 5 1 2.
Two Sum (*)
C. Given an array of integers arr[0..n-1], count all pairs (arr[i], arr[j]) in it such that i*arr[i] >
j*arr[j], 0 =< i < j < n.
Example:
Input: arr[] = {5, 0, 10, 2, 4, 1, 6}
Pairs which hold condition i*arr[i] > j*arr[j] are
(10, 2) (10, 4) (10, 1) (2, 1) (4, 1)

Given an array of integers nums and an integer target, return indices of the two
numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not
use the same element twice.
You can return the answer in any order.
Example 1:
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Output: Because nums[0] + nums[1] == 9, we return [0, 1].
Example 2:
Input: nums = [3,2,4], target = 6
Output: [1,2]
Example 3:
Input: nums = [3,3], target = 6
Output: [0,1]
Constraints:
• 2 <= nums.length <= 105
• -109 <= nums[i] <= 109
• -109 <= target <= 109
• Only one valid answer exists.

Add Two Numbers (**)


You are given two non-empty linked lists representing two non-negative integers. The
digits are stored in reverse order and each of their nodes contain a single digit. Add
the two numbers and return it as a linked list.
You may assume the two numbers do not contain any leading zero, except the number
0 itself.
Example:
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8
Explanation: 342 + 465 = 807.

You might also like