Skip to content

This repository contains solutions to a series of programming exercises aimed at developing fundamental problem-solving skills using C++. The tasks focus on basic arithmetic operations, user input, and logical implementations.

Notifications You must be signed in to change notification settings

MMTalal/CPP-Programming-Assignment-1-Solutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ Programming Assignment 1 Solutions

Overview

This repository contains solutions to a series of programming exercises aimed at developing fundamental problem-solving skills using C++. The tasks focus on basic arithmetic operations, user input, and logical implementations.

Assignments

1. Print an Integer

  • Description: Write a program that takes an integer input from the user and prints it.
  • Example:
    • Input: 5
    • Output: 5

2. Sum of Three Integers

  • Description: Write a program that asks the user to input three integers and outputs their sum.
  • Example:
    • Input:
      Please enter first number: 5
      Please enter second number: 3
      Please enter third number: 4
      
    • Output: Summation of 3 integers is 12

3. Average of Three Integers

  • Description: Write a program that calculates the average of three integers entered by the user and displays the result as a decimal number.
  • Example:
    • Input:
      Please enter first number: 6
      Please enter second number: 4
      Please enter third number: 4
      
    • Output: The average = 4.66667

4. Perimeter and Area of a Rectangle

  • Description: Write a program to compute the perimeter and area of a rectangle based on user-input width and height.
  • Example:
    • Input:
      Width = 5
      Height = 3
      
    • Output:
      The perimeter = 16
      The area = 15
      

5. Sum of the Digits of a 3-Digit Number

  • Description: Write a program that calculates the sum of the digits of a three-digit number entered by the user.
  • Example:
    • Input: 132
    • Output: 6

6. Time Conversion

  • Description: Write a program that converts a given integer (representing seconds) into hours, minutes, and seconds.
  • Example:
    • Input: 25300
    • Output: H:M:S - 7:1:40

How to Run the Programs

  1. Make sure you have a C++ compiler installed (e.g., GCC or an IDE like Visual Studio Code).
  2. Clone this repository or copy the program code into your local environment.
  3. Compile the code using the command:
    g++ -o output_name program_name.cpp
  4. Run the compiled program:
    ./output_name
  5. Follow the prompts for user input.

Notes

  • Each program is implemented as a standalone C++ file.
  • Ensure proper formatting of user input for accurate results.
  • Comments are included in the code to explain the logic and computations.

License

This project is licensed under the MIT License.

About

This repository contains solutions to a series of programming exercises aimed at developing fundamental problem-solving skills using C++. The tasks focus on basic arithmetic operations, user input, and logical implementations.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages