## Write C++ program to find the largest number among three numbers

A number will be largest if number is greater than both the other numbers.

``````#include <iostream>
using namespace std;
int main() {
float a, b, c;
cin >> a >> b >> c;
if(a >= b && a >= c)
cout << "Largest number: " << a;
if(b >= a && b >= c)
cout << "Largest number: " << b;
if(c >= a && c >= b)
cout << "Largest number: " << c;
return 0;
}
Input: 1 2 3
Largest number: 3``````
[mai mult...]

## Write a program to swap two numbers in C++

We will use a temporary variable to store one of the numbers to perform the swap operation.

[mai mult...]

## Program to Check if a number is even or odd in C++

To Check if a given number is even or odd we simply divide the given number by 2, if the remainder is 0 then it is even otherwise odd.

[mai mult...]

## Write a program for Adding two numbers in C++

To Add two numbers in C++ we will read two numbers a and b from the user then perform add operation to add a and b together to print the addition of two numbers in C++.

[mai mult...]

## C++ Program to Add Two Distances System Using Structures

In this program, a structure `Distance` containing two data members (inch and feet) is declared to store the distance in the inch-feet system.Here, two structure variables d1 and d2 are created to store the distance entered by the user. And, the sum variable stores the sum of the distances.

[mai mult...]

## C++ Program to Add Complex Numbers by Passing Structure to a Function

In this program, two complex numbers entered by the user are stored in the structures num1 and num2.

• These two structures are passed to `addComplexNumbers()` function which calculates the sum and returns the result to the `main()` function.
• This result is stored in the structure complexSum.
• Then, the sign of the imaginary part of the sum is determined and stored in the `char` variable signOfImag.
• If the imaginary part of complexSum is positive, then signofimag is assigned the value `'+'`. Else, it is assigned the value `'-'`
• We then adjust the value of complexSum.imag.
• This code changes complexSum.imag to positive if it is found to be of negative value.
• This is because if it is negative, then printing it along with signofimag will give us two negative signs in the output.
• So, we change the value to positive to avoid sign repetition.
• After this we finally display the sum.
[mai mult...]

## C++ Program to Calculate Difference Between Two Time Period

In this program, user is asked to enter two time periods and these two periods are stored in structure variables t1 and t2 respectively. Then, the `computeTimeDifference()` function calculates the difference between the time periods and the result is displayed on the screen from the `main()` function without returning it (call by reference).

[mai mult...]

## C++ Program to Store and Display Information Using Structure

In this program, a structure, student is created.

This structure has three members: name (string), roll (integer) and marks (float). Then, we created a structure array of size 10 to store information of 10 students. Using for loop, the program takes the information of 10 students from the user and displays it on the screen.

[mai mult...]

## Write a C++ program to find the largest number among three numbers

A number will be largest if number is greater than both the other numbers.

[mai mult...]

## Write a program to swap two numbers in C++

We will use a temporary variable to store one of the numbers to perform the swap operation.

[mai mult...]