Posts

Showing posts from October, 2024

Master Your Finances: C++ Program to Calculate Monthly Expenses!

Image
Total Expense Calculation : Objective: Master Your Finances: C++ Program to Calculate Monthly Expenses! Problem Description: You need to compute the total expenses given daily expenses for a week and the number of weeks in a month. Task: 1. Declare variables to store: ○ Daily expense amount ○ Number of weeks in a month 2. Take input for the daily expense and the number of weeks from the user. 3. Calculate the total expense as follows: TotalExpense=Daily Expense×7×Number of Weeks 4. Display the result in a clear format. Solution: Code: #include<iostream> using namespace std; int main(){ cout<<"The Total Expenses Over a Month"<<endl; cout<<"-------------------------------"<<endl; int daily_expense; int num_week_month; int total_expense; cout<<"Enter Daily Expense: "<<endl; cin>>daily_expense; cout<<"Enter The Number of Weeks: "<<endl; cin>>num_week_month; total_expense=(daily_expense...

No Loops, No Problem: Mastering Digit Reversal in C++

Image
Problem Description: No Loops, No Problem: Mastering Digit Reversal in C++ Write a C++ program that takes a three-digit number as input and prints the number with its digits reversed. For example, if the input is 123, the output should be 321. Task: 1. Declare a variable to store the three-digit number. 2. Use arithmetic operations (division and modulus) to extract the digits of the number. 3. Rearrange and print the digits in reverse order. Input Format: ● Take three digit number from user e.g 123 Output Format: ● The number with its digits reversed. E.g 321 Solution: Code: #include <iostream> using namespace std; int main(){ cout<<"Rearrange and Print the Digits in Reverse Order"<<endl; cout<<"-----------------------------------------------"<<endl; int num; cout<<"Enter Number for Reverse: "<<endl; cin>>num; int last_number=num%10; int middle_number=(num/10)%10; int first_number=num/100; cout<<last_nu...

C++ Challenge: Adding, Subtracting, and Multiplying Complex Numbers Simply

Image
Objective: C++ Challenge: Adding, Subtracting, and Multiplying Complex Numbers Simply Write a C++ program to perform addition, subtraction, and multiplication on two complex numbers without using loops, functions, or classes. You will handle the real and imaginary parts of the complex numbers manually. Problem Description: A complex number is represented as a+bi where: ● a is the real part. ● a is the imaginary part. For two complex numbers, represented as (a1 + b1i) and (a2 + b2i) perform the following operations: Addition: Add the real parts and the imaginary parts separately. Sum=(a1+a2)+(b1+b2)i Subtraction: Subtract the real parts and the imaginary parts separately. Difference=(a1−a2)+(b1−b2)i Multiplication: Use the following formula to multiply the complex numbers: Product=”create the logic on your own” Task: 1. Declare four variables to store the real and imaginary parts of the two complex numbers. 2. Take input for the real and imaginary parts of both complex numbers from the ...

C++ Program to Find the Area and Circumference of a Circle

Image
  C++ Program to Find the Area and Circumference of a Circle I'll show you how to use C++ to find the area and circumference of a circle in this post. One of the most fundamental geometric shapes is the circle, and understanding how to calculate its properties is an excellent way to comprehend formulas and how to use them in programming. Basic:  ✔ ✔  Area = π * r²  ✔✔ Circumference = 2 * π * r                                                                                                                                                                      ...

My First C++ Program: Hello World

Image
Welcome to my first blog post! In this post, I'll be sharing the very first C++ program every beginner writes. the classic "Hello World" program. This program is simple but marks the start of an exciting journey into the world of coding. (Code) : // My First C++ Program (Hello World) #include <iostream>  using namespace std;  int main() {      cout<<"Hello World"<<endl;           return 0; } Out Put:  Thanks......