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

Cs112 - Programming Fundamental: Lecture # 23 - Practice Exercises Syed Shahrooz Shamim

This document contains instructions for 14 practice exercises for a programming fundamentals lecture. The exercises include writing programs to: swap variable values, calculate years/months/days from input days, check triangle validity from angles, break down amounts into denominations, check for leap years, find youngest of three ages, print and calculate with numbers, calculate factorials, raise numbers to powers, reverse integers, calculate digit sums and primality, find highest common factors, count positive/negative/zero numbers, and find maximums/minimums. It also includes programs for Armstrong numbers, Fibonacci series, calculating series sums, and calculating natural logarithms through series additions.

Uploaded by

Ghazan Aqeel
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views

Cs112 - Programming Fundamental: Lecture # 23 - Practice Exercises Syed Shahrooz Shamim

This document contains instructions for 14 practice exercises for a programming fundamentals lecture. The exercises include writing programs to: swap variable values, calculate years/months/days from input days, check triangle validity from angles, break down amounts into denominations, check for leap years, find youngest of three ages, print and calculate with numbers, calculate factorials, raise numbers to powers, reverse integers, calculate digit sums and primality, find highest common factors, count positive/negative/zero numbers, and find maximums/minimums. It also includes programs for Armstrong numbers, Fibonacci series, calculating series sums, and calculating natural logarithms through series additions.

Uploaded by

Ghazan Aqeel
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

CS112 - PROGRAMMING FUNDAMENTAL

Lecture # 23 – Practice Exercises


Syed Shahrooz Shamim
Junior Lecturer,
CS Department, UIT
• Write a program to swap the values of two
variables.
• Write a program which accepts days as integer and
display total number of years, months and days in it.
for example : If user input as 856 days the output
should be 2 years 4 months 6 days.
• Write a program to check whether a triangle is
valid or not, when the three angles of the triangle
are entered by the user.
• Write a program which accepts amount as integer
and display total number of Notes of Rs. 500, 100,
50, 20, 10, 5 and 1.
For example, when user enter a number, 575,
the results would be like this...
500: 1, 100: 0, 50: 1, 20: 1, 10: 0, 5: 1, 1: 0
• Any year is input by the user. Write a program to
determine whether the year is a leap year or not.
• If the ages of Affan, Afnan and Adnan are input by
the user, write a program to determine the youngest
of the three.
• Write a program to print number from 1 to 10.
• Write a program to calculate the sum of first 10
natural number.
• Write a program to find the factorial value of any
number entered through the keyboard.
• Two numbers are entered through the keyboard.
Write a program to find the value of one number
raised to the power of another.
• Write a program to reveres any given integer
number.
• Write a program to sum of digits of given integer
number.
• Write a program to check given number is prime or
not.
• Write a program to calculate HCF of Two given
number.
• Write a program to enter the numbers till the user
wants and at the end it should display the count of
positive, negative and zeros entered.
• Write a program to enter the numbers till the user
wants and at the end it should display the maximum
and minimum number entered.
• Write a program to print out all Armstrong numbers
between 1 and 500. If sum of cubes of each digit of
the number is equal to the number itself, then the
number is called an Armstrong number.
For example, 153=(1*1*1)+(5*5*5)+(3*3*3)
• Write a program to print Fibonacci series of n terms
where n is input by user : 0 1 1 2 3 5 8 13 24 .....
• Write a program to calculate the sum of following
series where n is input by user.
1 + 1/2 + 1/3 + 1/4 + 1/5 +…………1/n
• Compute the natural logarithm of 2, by adding up to
n terms in the series
1 - 1/2 + 1/3 - 1/4 + 1/5 -... 1/n
where n is a positive integer and input by user.
• Write a program to print following
• Write a program to print following

You might also like