C++ Programming
- Write a C++ Program to print a welcome text in a separate line.
- Write a Program in C++ to add two numbers.
- C++ program for addition of two numbers using functions.
- Add two numbers in C++ using class.
- Addition of two numbers using call by reference in C++
- C++ program to write a program to add two numbers using call by value.
- Swapping of two numbers in C++ without using third variable.
- Swap two numbers in C++ using function.
- C++ program to swap two numbers using class.
- C++ program to swap two numbers using call by value.
- C++ program to swap two numbers using pointers.
- Write a program to swap private data members of two classes using friend function.
- write a program to add data objects of two different classes using friend function.
- Threading in C++.
- C++ thread lambda
- C++ thread lambda with parameter
- C++ thread lambda pass by reference
- Singleton C++ example
Explain the following definitions. For those that are illegal, explain what’s wrong and how to correct it. (a) std::cin >> int input_value; (b) int i = { 3.14 }; (c) double salary = wage = 9999.99; (d) int i = 3.14;
(a) ‘int’ will not be defined after cin. It is illegal. The correct way is
int input_value = 0;
std::cin>>input_value;
(b) 3.14 is a float value, so it will not initialize an integer value. It is illegal. The correct way is
float i = {3.14};
(c) It is illegal. ‘wage’ is not declared in this scope. The correct one is
double wage = 9999.99;
double salary = wage;
(d) It will not show any error. But the value will be truncated. It will display a value of 3. So it is illegal. The correct way is
float i = 3.14;