0% found this document useful (0 votes)
52 views

List of Programs

Uploaded by

feyina8823
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)
52 views

List of Programs

Uploaded by

feyina8823
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/ 9

List of programs

1. Write a program to perform addition of two numbers.


2. Write a program to perform subtraction of two numbers.
3. Write a program to perform multiplication of two numbers.
4. Write a program to perform division of two numbers.
5. Write a program to perform modulo operation.
6. Write a program explaining ternary operator.
7. Write simple program using increment and decrement operator.
Programs on if statement
8. Write a program to accept two integers and check whether they are equal or not.
9. Write a program to check whether a given number is positive or negative.
10.Write a program to find whether a given year is a leap year or not.
11.Write a program to calculate the root of a Quadratic Equation.
12.Write a program to check whether a triangle can be formed by the given value for the
angles.
13.Write a program to check whether a character is an alphabet, digit or special
character.
14.Write a program to check whether an alphabet is a vowel or consonant.
15.Write a program to check whether a triangle is Equilateral, Isosceles or Scalene.
16.Write a program to read any day number in integer and display day name in the
word.
17.Write a program to accept a coordinate point in a XY coordinate system and
determine in which quadrant the coordinate point lies.

Programs on loop
18. Write a program to find the sum of first 10 natural numbers.
19.Write a program to display n terms of natural number and their sum.
20.Write a program to display the cube of the number upto given an integer.
21.Write a program to display the multiplication table of a given integer.
22.Write a program to calculate the factorial of a given number.
23.Write a program to display the n terms of even natural number and their sum.
24.Write a program to display the sum of the series [ 9 + 99 + 999 + 9999 ...].
25.Write a program to check whether a given number is an armstrong number or not.
26.Write a program to determine whether a given number is prime or not.
27.Write a program to display the first n terms of Fibonacci series.
28.Write a program to display the number in reverse order.
Example: Input 12345 Output 54321
29.Write a program to check whether a number is a palindrome or not.

Pattern programs
30. Write a program to display the pattern like right angle triangle using an asterisk. The
pattern like :
*
**
***
****
31.Write a program to display the pattern like right angle triangle with a number. The
pattern like:
1
12
123
1234
32.Write a program 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
33.Write a program to make such a pattern like right angle triangle with number
increased by 1. The pattern like:
1
23
456
78910
34.Write a program to make such a pattern like a pyramid with numbers increased by 1.
The pattern like:
1
23
456
78910
35. Write a program to print following pattern…
*****
*****
*****
*****
36.. Write a program to print following pattern…
*****
* *
* *
******
37. Write a program to print following pattern…
*****
****
***
**
*
38. Write a program to print following pattern…
*****
* *
**
**
*
39. Write a program to print following pattern…
*****
****
***
**
*
40. Write a program to print following pattern…
*****
* *
**
**
*
41. Write a program to print following pattern…
*
***
*****
*******
42. Write a program to print following pattern…
*
**
* *
* *
*********
43. Write a program to print following pattern…
*
**
***
****
***
**
*
44. Write a program to print following pattern…
*
**
***
****
***
**
*
Array programs
45. Write a program to read n number of values in an array and display it in reverse
order.
46.Write a program to copy the elements of one array into another array.
47.Write a program to count a total number of duplicate elements in an array.
48.Write a program to print all unique elements in an array.
49.Write a program to merge two arrays of same size sorted in decending order.
50.Write a program to count the frequency of each element of an array.
51.Write a program to find the maximum and minimum element in an array.
52.Write a program to separate odd and even integers in separate arrays.
53.Write a program to sort elements of array in ascending order.
54. Write a program to delete an element at desired position from an array.

Function programs
55. Write a program to find the square of any number using the function.
56. Write a program to swap two numbers using function.
57. Write a program to check a given number is even or odd using the function.
58. Write a program to check whether a number is a prime number or not using the
function.
59. Write a program to get the largest element of an array using the function.
60. Write a program to check armstrong and perfect numbers using the function.
61. Write a program to print all perfect numbers in given range using the function.
62. Write a program to find out maximum and minimum of some values using function
which will return an array.
63. Write a program to find the sum of the series 1!/1+2!/2+3!/3+4!/4+5!/5 using the
function.
64. Write a program to convert decimal number to binary number using the function.

Switch programs
65.Write a program to read weekdays number and print weekday name using switch.
66.Write a program to read gender and print corresponding gender using switch.
67.Write a program to check whether a character is VOWEL or CONSONANT using
switch.
68.Write a program to design calculator with basic operations using switch and also
include features of scientific calculator.
69.Write a program to check whether number is even or odd using switch.
70.Write a program to find the number of days in month using switch case.
71.Write a program to find the maximum between two numbers using switch case.
72.Write a program to check whether the number is positive, negative or zero using
switch case.
73.Write a program to find roots of a quadratic equation using switch case.
Basic programs
74. Write a program to convert specified days into years, weeks and days.
75. Write a program that accepts an employee's ID, total worked hours of a month and
the amount he received per hour. Print the employee's ID and salary (with two
decimal places) of a particular month.
76. Write a program to calculate the distance between the two points.
77. Write a program to read an amount (integer value) and break the amount into
smallest possible number of bank notes.
78. Write a program to convert a given integer (in seconds) to hours, minutes and
seconds.
79. Write a program to convert a given integer (in days) to years, months and days,
assumes that all months have 30 days and all years have 365 days.
80. Write a program that accepts 4 integers p, q, r, s from the user where r and s are
positive and p is even. If q is greater than r and s is greater than p and if the sum of r
and s is greater than the sum of p and q print "Correct values", otherwise print
"Wrong values".
81. Write a program that read 5 numbers and sum of all odd values between them.
82. Write a program that prints all even numbers between 1 and 50 (inclusive).
83. Write a program that read 5 numbers and counts the number of positive numbers
and negative numbers.
84. Write a program that read 5 numbers and counts the number of positive numbers
and print the average of all positive values.
85.Write a program to find and print the square of each one of the even values from 1 to
a specified value.
86.Write a program to check whether a given integer is positive even, negative even,
positive odd or negative odd. Print even if the number is 0.
87.Write a program to print all numbers between 1 to 100 which divided by a specified
number and the remainder will be 3.
88.Write a program that accepts some integers from the user and find the highest value
and the input position.
89.Write a program to read a password until it is correct. For wrong password print
"Incorrect password" and for correct password print "Correct password" and quit the
program. The correct password is 1234.
90.Write a program to read the coordinates(x, y) (in Cartesian system) and find the
quadrant to which it belongs (Quadrant -I, Quadrant -II, Quadrant -III, Quadrant -IV).
91.Write a program that reads two numbers and divide the first number by second
number. If the division not possible print "Division not possible".
92.Write a program to find all numbers which are dividing by 7 and the remainder is
equal to 2 or 3 between two given integer numbers.
93.Write a program to print 3 numbers in a line, starting from 1 and print n lines. Accept
number of lines (n, integer) from the user.
Pointer programs
94. Write a program to show the basic declaration of pointer.
95.Write a program to demonstrate the use of &(address of) and *(value at address)
operator.
96. Write a program to add two numbers using pointers.
97.Write a program to add numbers using call by reference.
98.Write a program to find the maximum number between two numbers using a
pointer.
100.Write a program to store n elements in an array and print the elements using
pointer.
101. Write a program to print all permutations of a given string using pointers.
Expected Output :
The permutations of the string are :
abcd abdc acbd acdb adcb adbc bacd badc bcad bcda bdca bdac cbad cbda
cabd cadb cdab cdba dbca dbac dcba dcab dacb dabc
102. Write a program to find the largest element using Dynamic Memory Allocation
103. Write a program to swap elements using call by reference.
104. Write a program to find the factorial of a given number using pointers.
105. Write a program to count the number of vowels and consonants in a string using a
pointer.
106. Write a program to Calculate the length of the string using a pointer.
107. Write a program to sort an array using Pointer.
108. Write a program to compute the sum of all elements in an array using pointers.
109. Write a program to print the elements of an array in reverse order.

String Programs
110. Write a program to input a string and print it.
111. Write a program to find the length of a string without using library function.
112. Write a program to separate the individual characters from a string.
113. Write a program to print individual characters of string in reverse order.
114. Write a program to compare two string without using string library functions.
115. Write a program to count total number of alphabets, digits and special characters in
a string.
116. Write a program to sort a string array in ascending order.
117. Write a program to demonstrate strcat
118. Write a program to demonstrate the working of strrchr()
119. Write a program to illustrate strcpy() function.

Class and object programs


120. Create a class named 'Student' with a string variable 'name' and an integer variable
'roll_no'. Assign the value of roll_no as '2' and that of name as "xyz" by creating an
object of the class Student.
121. Assign and print the roll number, phone number and address of two students
having names "xyz" and "abc" respectively by creating two objects of the class
'Student'.
122. Write a program to print the area and perimeter of a triangle having sides of 3, 4
and 5 units by creating a class named 'Triangle' with a function to print the area and
perimeter.
123. Write a program to print the area and perimeter of a triangle having sides of 3, 4
and 5 units by creating a class named 'Triangle' with the constructor having the
three sides as its parameters.
124. Write a program to print the area of two rectangles having sides (4,5) and (5,8)
respectively by creating a class named 'Rectangle' with a function named 'Area'
which returns the area. Length and breadth are passed as parameters to its
constructor.
125. Print the average of three numbers entered by the user by creating a class named
'Average' having a function to calculate and print the average without creating any
object of the Average class.
126. Write a program that would print the information (name, year of joining, salary,
address) of three employees by creating a class named 'Employee'. The output
should be as follows: Name Year of joining Address xyz 2000 Facebook tower abc
2015 google street
127. Write a program by creating an 'Employee' class having the following functions and
print the final salary.
1 - 'getInfo()' which takes the salary, number of hours of work per day of employee
as parameters
2 - 'AddSal()' which adds 1000 to the salary of the employee if it is less than 5000.
3 - 'AddWork()' which adds 500 to the salary of the employee if the number of
hours of work per day is more than 6 hours.

Inheritance programs
128. Create a class with a function that prints "This is parent class" and its subclass with
another function that prints "This is child class". Now, create an object for each
class and call 1 - function of the parent class by the object of the parent class 2 -
function of the child class by the object of the child class 3 - function of the parent
class by the object of the child class
129. Create a class named 'Member' having the following members: Data members 1 -
Name 2 - Age 3 - Phone number 4 - Address It also has a function named
'printSalary' which prints the salary of the members. Two classes 'Employee' and
'Manager' inherits the 'Member' class. The 'Employee' and 'Manager' classes have
data members 'specialization' and 'department' respectively. Now, assign name,
age, phone number, address and salary to an employee and a manager by making
an object of both of these classes and print the same.
130. Create a class named 'Rectangle' with two data members 'length' and 'breadth' and
two functions to print the area and perimeter of the rectangle respectively. Its
constructor having parameters for length and breadth is used to initialize the length
and breadth of the rectangle. Let class 'Square' inherit the 'Rectangle' class with its
constructor having a parameter for its side (suppose s) calling the constructor of its
parent class. Print the area and perimeter of a rectangle and a square.
131. Now repeat the above example to print the area of 10 squares. Hint-Use array of
objects
132. Create a class named 'Shape' with a function to print "This is a shape". Then create
two other classes named 'Rectangle' and 'Circle' inheriting the Shape class, both
having a function to print "This is rectangular shape" and "This is circular shape"
respectively. Create a subclass 'Square' of 'Rectangle' having a function to print
"Square is a rectangle". Now call the function of the 'Shape' and the 'Rectangle'
class by the object of the 'Square' class.

Exceptional Handling
133. Write a program containing a possible exception. Use a try block to throw it and a
catch block to handle it properly.
134. Write a program that illustrates the application of multiple catch statements.
135. Write a program which uses catch(...) handler.
136. Write a program that demonstrates how certain exception types are not allowed to
be thrown.
137. Write a program to demonstrate the concept of rethrowing an exception.
138. Write a program with the following:
(a) A function to read two double type numbers from keyboard
(b) A function to calculate the division of these two numbers
(c) A try block to throw an exception when a wrong type of data is keyed in
(d) A try block to detect and throw an exception if the condition "divide-by-zero"
occurs
(e) Appropriate catch block to handle the exceptions thrown
139. Write a main program that calls a deeply nested function containing an exception
Incorporate necessary exception handling mechanism.

You might also like