0% found this document useful (0 votes)
6 views4 pages

Assignment 5 - Loops

Assignment 5 for Programming Fundamentals focuses on loops in C++ and aims to enhance programming logic and control flow understanding. It includes various tasks such as temperature conversion, date formatting, logic gates, GCD calculation, and more, with specific submission guidelines and requirements. The assignment must be handwritten, scanned, and submitted by May 18, 2025, with each question answered in separate C++ programs.

Uploaded by

saimrajput7935
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)
6 views4 pages

Assignment 5 - Loops

Assignment 5 for Programming Fundamentals focuses on loops in C++ and aims to enhance programming logic and control flow understanding. It includes various tasks such as temperature conversion, date formatting, logic gates, GCD calculation, and more, with specific submission guidelines and requirements. The assignment must be handwritten, scanned, and submitted by May 18, 2025, with each question answered in separate C++ programs.

Uploaded by

saimrajput7935
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/ 4

Assignment 5 - Loops

Welcome to Assignment 5 for the course on Programming Fundamentals. This assignment focuses
on Loops in C++. The purpose of this assignment is to strengthen your programming logic and
control flow understanding through practical tasks involving loops and conditionals. You will write
C++ programs using only standard libraries (specifically stdlib.h for srand() if required).

Submission Guidelines

Deadline: 18th May, 2025 (Sunday), by 11:00 PM (Midnight).


Mode of Submission: LMS (Learning Management System).
Format: Handwritten solutions must be scanned and submitted as a .doc or .docx file.
Important: Assignments not written on the official assignment paper will not be
accepted.
No additional files or material should be included.

Instructions

Do not use external libraries.


Input and output operations should be clear and interactive.
Each question should be answered in a separate C++ program.
Follow proper naming conventions and indentation.

Questions

Q1 - Temperature Converter

Write a program that allows a user to choose between:

Celsius to Fahrenheit: (C × 1.8) + 32


Fahrenheit to Celsius: ((F − 32) × 5) / 9

Prompt for input temperature and convert accordingly. Loop this process for multiple conversions.

Q2 - Date Formatter

Prompt user to enter date as three integers: month, day, year. Output formatted like:

31st December 2003

Add correct suffixes (st, nd, rd, th). Repeat input collection.

Q3 to Q8 - Logic Gates and Truth Tables

Write programs to display truth tables:


Q3: AND gate and Commutative property
Q4: OR gate and Associative property
Q5: Distributive property of OR over AND
Q6: Distributive property of AND over OR
Q7: De Morgan’s Law ¬(A ∨ B) = ¬A ∧ ¬B
Q8: De Morgan’s Law ¬(A ∧ B) = ¬A ∨ ¬B

Allow user to choose and repeat.

Q9 - GCD Calculator
Calculate GCD of two given integers using Euclidean Algorithm.

Q10 - Minimum Finder

Input 30 numbers and find the minimum value.

Q11 - Maximum Finder

Input 30 numbers and find the maximum value.

Q12 - Permutation Calculator

Compute P(n, r) = n! / (n - r)! using a factorial.

Q13 - Power Function


Calculate base^exponent, e.g. 2^5 = 32.

Q14 & Q15 - Number Base Conversion

Q14: Convert Octal to Binary


Q15: Convert Binary to Octal

Q16 - Fibonacci Series


Print Fibonacci sequence under 150.

Q17 - Armstrong Number Checker

Check if input number is Armstrong number.

Q18 - Factor Finder

List all factors of a given number.

Q19 - Number Reverser

Reverse the digits of a given number.


Q20 - Palindrome Checker

Check if a number reads the same forwards and backwards.

Q21 - LCM Calculator

Find LCM of two numbers using GCD-based approach.

Q22 - Perfect Number Checker

Check if number is equal to the sum of its proper divisors.

Q23 - 1’s Complement

Print the 1’s complement of a binary number.

Q24 - Digit Swapper

Swap first and last digits of a given number and generate the new number after swapping.

Q25 - Number to Words

Print digits of a number in words (e.g., 123 → One Two Three).

Q26 to Q29 - Pattern Printing

Print shapes with loops:

Q26: Numeric triangle shape


Q27: Alphabet triangle shape
Q28: Alphabet V-shape
Q29: Numeric V-shape

Bonus Question

Write a C++ program that:

Accepts a range of numbers


Prints the frequency of each digit (0–9)

Sample Output 1:
Enter the starting value: 5
Enter the ending value: 15

Digit Frequency
0 1
1 7
2 1
3 1
4 1
5 2
6 1
7 1
8 1
9 1

Sample Output 2:

Enter the starting value: 0


Enter the ending value: 30

Digit Frequency
0 3
1 13
2 13
3 4
4 3
5 3
6 3
7 3
8 3
9 3

You might also like