Fundamentals of Physics Textbook
Fundamentals of Physics Textbook
Programming
Md. Mahmudur Rahman
[email protected]
Contents
• C++
• Escape Sequence & Comments
• Variables
• Constants
• User Input
• Data Types
• Operators
• Strings & String Concatenation
• Append
• User Input Strings
• Math’s
What is C++
{
cout << "Hello World!";
return 0;
}
Escape Sequence & Comments
❑New Line--To insert a new line, you can use the \n character or
endl.
❑Horizontal tab-- \t
❑Backslash character (\)--\\
❑Double quote character-- \”……\”
int x, y, z;
int x = 2, y = 4, z = 4;
x = y = z = 10;
cout << x + y + z;
cout << x + y + z;
Constants
1. Arithmetic operators
2. Assignment operators
3. Comparison operators
4. Logical operators
Arithmetic operators
Arithmetic operators are used to perform common mathematical operations.
Assignment Operators
= x = 5, x=5 int main() { int main() { int main() {
int x = 3; double x = 5; int x = 5;
+= x += 3 x=x+3 x += 3; x /= 2; x %= 2;
cout << x; cout << x; cout << x;
-= x -= 3 x=x-3
*= x *= 3 x=x*3
/= x /= 3 x=x/3
%= x %= 3 x=x%3
Comparison Operators
• Comparison operators are used to compare two values.
• The return value of a comparison is either true (1) or false (0).
string fullName;
when working with strings, we often use the getline()
cout << “Enter Your Full Name: ";
function to read a line of text. It takes cin as the first
getline (cin, fullName);
parameter, and the string variable as second
cout << "Your Name is: " << fullName;
Math's