Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Simple Programs
• Display the following
Your address.
Your Biodata.
Names of high level languages and low level languages.
Names of operating system.
Names of data type and number of bytes taken by them.
• Calculate the total marks if marks of three subjects are given
• Calculate the percentage if obtained marks & maximum of three subjects are
given.
• Calculate the Area/Perimeter of Circle/Square/Rectangle/Triangle
• Calculate the volume of Sphere/ Cuboid/ Cylinder
• Read price of an item in real form (like 75.95) & print the output in paise (like
7595 paise)
• Convert angle given in Degree into Radian & vice versa
• Convert temperature given in Celsius into Fahrenheit & vice versa
• Perform arithmetic operations (Addition, Subtraction, Multiplication, Division) on
two numbers
• Evaluate the expressions using Library functions.
If-Else
• Check given no is +ve /-ve/zero/even/odd
• Solve Quadratic equation
• Find maximum/minimum of three numbers.
• Change the case of letter
• Check given year is Leap or not
• Check whether a given character is alphabet /digit /vowel/consonant /special
character.
• Display the name of Color/Month/Weekday according to given choice.
• Perform the arithmetic operation (Addition/ Subtraction/ Multiplication /Division)
on two numbers according to the given choice.
• Calculate the Area/ Perimeter of Triangle/ Circle/ Rectangle according to the
given choice.
• Display Pass or Fail according to the given percentage
Per>= 48 Pass
Per < 48 Fail
• Calculate whether student is passed in first division, second division, third
division or fail according to the given percentage with the following criteria
Per>= 60 First 48<=Per< 60 Second
33<=Per< 48 Third Per< 33 Fail
1/7
• Read date of birth of a student & display days of month of her birth.
LOOP
• Find the factorial of a given number
• Find the number whose factorial is given
• Find the nth term of Fibonacci series.
• Find the sum of all /odd /even/odd positioned/even positioned digits of a
given number.
• Find the sum of digits of a given number until sum exceeds 20.
• Check whether two given numbers are consecutive fibonacci numbers or not
• Check whether the given number is prime /Armstrong /magic /perfect /
palindrome.
• Display all the prime numbers in a given range.
• Find all exact divisors of given positive numbers.
• Find smallest divisors of given number.
• Find all even/odd numbers in a given range.
• Find GCD of N positive non zero integers.
• Find the number of and sum of all the integers greater than 100 & less than
200 that are divisible by 7.
• Accept N numbers from user and display sum of even & odd numbers
separately.
• Generate the table of given number.
• Find the reverse of a given number.
• Read a real number from the keyboard & print the following output in one line
Smallest integer Given number Largest integer
not less than not greater than
the number the number
• Find HCF & LCM of two given numbers.
• Find maximum of 4 numbers.
• Find out total hours, minutes, seconds in a given time where time is given in
seconds.
• Read a positive number n & generate the numbers in following form
Entered number is 5
Output is 5 4 3 2 1 0 1 2 3 4 5
• Check whether the given digit is present in given number, is yes then count
the occurrence of digit in that number
• Check whether the given digit is present in given number, is yes then count
the position of digit in that number
• Read a number n & display digit by digit as a series of words eg. 756 should
be displayed as “Seven Five Six”.
2/7
• Read a number n & display it as a series of words eg. 756 should be displayed
as “Seven Hundred Fifty Six.
Patterns
* ***** * *
** **** *** ***
*** *** ***** *****
**** ** ******* *******
***** * ********* *****
***
*
* +* ******* *
** ++** ***** ***
*** +++*** *** *****
++++**** * ***
*
1 1 1 $ $ $ $ $
22 12 2 2 $ $ $ $
333 123 3 3 3 $ $ $
4444 1234 4 4 4 4 $ $
55555 12345 5 5 5 5 5 $
1 1 ABCDEFG A
2 2 23 ABCDE AB
3 3 3 456 ABC ABC
4 4 4 4 78910 A AB
5 5 5 5 5 A
123454321 ABCDEDCBA 0 1
1234 4321 ABCD DCBA 101 21
123 321 ABC CBA 21012 321
12 21 AB BA 3210123 4321
1 1 A A 432101234 54321
1 1
121 11
12321 121
1234321 1331
123454321 14641
1 5 10 10 5 1
3/7
Series
Find the sum of following Series up to n terms using For loop, While loop, Goto
statement
• 1+2+3+4+5+……….
• 1-2+3-4+5-……….
• 1+4+9+16+25+………..
• 1+8+27+65+125……….
• 1+3+5+7+9+…………
• 1+9+25+49+81+……….
• 4+16+36+64+…………
• 1+27+125+343+……..
• 8+64+216+512+……..
• 1+1+2+3+5+8+………..
• 1-3+5-7+9+…………
• 1!+2!+3!+4!+5!+………..
• 1+1/1!+1/2!+1/3!+1/4!+……………
• 12+22+32+42+52+………
• 1/12+1/22+1/32+1/42+…………
• 13+23+33+43+53+………
• 1/13+1/23+1/33+1/43+…………….
• 1-1/2+1/3-1/4+1/5+……………..
• 1/12-1/23+1/34-1/45+…………..
• x+(x2/2!)+(x3/3!)+(x4/4!)+…………(x is given by the user)
• x-(x3/3!)+(x5/5!)-(x7/7!)+………… (x is given by the user)
• (y+a)/1+(y+2a)/2+(y+3a)/3+………(y & a are given by the user)
• x+x^2+x^3+x^4+x^5+..…………..(x is given by the user)
• 1^1+2^2+3^3+4^4+………….
• 2/9-5/13+8/17-11/21…….
Find the sum of following Series
• sin(x), tan(x), log(x), cos(x)
Array
• Given a list of marks ranging from 1 to 100, write a program to compute & print
the number of students who have obtained marks
In range 81 to 100,
In range 61 to 80,
In range 41 to 60,
4/7
In range 0 to 40,
The program should use minimum number of if statements
• Read 20 numbers & display total multiples of 5.
• Sorting in Ascending/ Descending order (Bubble sort, Insertion sort, Selection
sort)
• Searching (Linear, Binary)
• Insertion of an element at last/first/specified position
• Compute the following where A, B, C are list of N numbers.
A = B + C ; A = B – C; A = B * C
• Conversion of Binary to Decimal / Octal/ Hexadecimal & vice versa
• Average/Minimum/Maximum of N numbers.
• Merging/ Concatenation/Append one list to another list.
• Delete all /first/ last occurrence of an element
• Delete an element from specified position.
• Reverse the elements of an array
• Find the sum of odd & even numbers separately.
• Find the sum of positive & negative numbers separately.
• Find largest even & largest odd number from a given list.
• Find Maximum & minimum element in a given list.
• Count odd & even numbers from the given list
• Count positive & negative numbers from the given list
• Split a list into two lists of even and odd numbers.
• Split a list into two lists of positive & negative numbers.
• Find all Pythagorean Triplets in the range 100 to 1000.
•
• To evaluate the following investment equation
V = P (1 + r)n
and print the tables which would give the value of V for various combination of the
following values of P, r and n.
P: 1000, 2000, 3000, …, 10000
r: 0.10, 0.11, 0.12, …, 0.20
n: 1, 2, 3, …, 10
P is the principal amount and V is the value of money at the end of n years. This
equation can be recursively written as
V = P (1 + r)
P=V
That is, the value of money at the end of first year becomes the principal amount for
the next year and so on.
• To print a two-dimensional Square Root Table as shown below, to provide the
square root of any number from 0 to 9.9. For example, the value x will give the
square root of 3.2 and y the square root of 3.9.
Square Root Table
Number 0.0 0.1 0.2 … 0.9
5/7
0.0
1.0
2.0
3.0 x y
9.0
Matrix
• Perform the operations (Addition, subtraction, Multiplication, Transposition, Row
wise Sum & Column wise Sum) on matrices
• Check whether the matrix is Unit/ Diagonal/ Symmetric/ Upper Triangular/ Lower
Triangular.
• To multiply/add/subtract/divide every element of a given matrix by a given
constant
• Find the determinant of an N*N matrix
String
• Count vowels, consonants, digits, spaces and special character.
• Count number of words and lines.
• Length of string.
• Reverse of string.
• Palindrome checking.
• Deletion of a given character/word.
• Frequency of a given character/word.
• Change case (lower, upper, title).
• Comparison (case sensitive, insensitive), concatenation, append and copy of two
strings.
• Insertion of given character/ word at first/ last/ specified position.
• Replace a given character/word by another given word/character.
• Replace each blank of a given String with underscore character (‘_’).
• Remove all the consonants from the given String.
• Generate all the permutation Strings from the given String.
Recursion
• Factorial of a number
• nth term of fibonacii series
• generate sum of n natural numbers
• solve Tower of Hanoi problem
6/7
• calculate xn.
• GCD of two numbers
• Minimum & Maximum value from the given list of numbers
• Check whether the given character is present in the given String.
• Find number of occurrences of given character in the given String.
• Replace each blank of a given String with underscore character (‘_’).
• Find Reverse of a given String.
• Remove all the consonants from the given String.
• Check whether the given String is palindrome or not.
• Generate all the permutation Strings from the given String.
Record
• Search a particular record of employee containing fields (empcode, empname)
• Sort record of employee containing fields (empcode, empname)
• Make a record of 5 students, having student name, age & marks in 3 subjects,
then find out the name of student with highest marks.
File
• Read a set of characters from keyboard and write them into sorted form in
FILE
• Read the data of ten employee and store the data in file
• Read the content from a file & show it on screen.
• Copy content of a file in another file.
• Create a file of numbers then store even & odd numbers of that file in two
separate files.
• Make copy of text file.
• Display contents of a text file.
• Change case of a given text file.
• Find total number of vowels, consonants, digits, spaces and special characters
in a given text file.
• Find frequency of a given character in a given text file.
• Count number of lines and number of words in a given text file.
• Merge two file of integers.
• Sort a given file of integers.
• Create file of record and update it.
7/7