Documente Academic
Documente Profesional
Documente Cultură
Management
FACULTY PRESENTATION
Dr. P. Ila Chandana Kumari
Professor
CSE
COURSE: OOPS T C++
23/09/20
© Copyrights 2018 HITAM. All rights reserved.
OOP Through C++ 1
1
Structure of C++ Program
# include <iostream>
using namespace std;
int main ()
{
cout << "Hello World! ";
cout << "I'm a C++ program";
}
• int i, j, k;
• char c, ch;
• float f, salary;
• double d;
• extern int d = 3, f = 5; // declaration of d and f.
• int d = 3, f = 5; // definition and initializing d and f.
• byte z = 22; // definition and initializes z.
• char x = 'x'; // the variable x has the value 'x'.
• #include <iostream>
• using namespace std;
• int main ()
• {
• // Local variable declaration:
• int a, b;
• int c;
• // actual initialization
• a = 10;
• b = 20;
• c = a + b;
• cout << c;
• return 0;
• }
• include <iostream>
• using namespace std;
• // Global variable declaration:
• int g;
• int main ()
• {
• // Local variable declaration:
• int a, b;
• // actual initialization
• a = 10;
• b = 20;
• g = a + b;
• cout << g;
• return 0;
• }
f = 70.0/3.0;
• All the data types of the variables are upgraded to the data type of the variable with largest data type.
bool –> char -> short int -> int -> unsigned int -> long -> unsigned -> long long -> float -> double -> long double
• It is possible for implicit conversions to lose information, signs can be lost (when signed is implicitly converted to
unsigned), and overflow can occur (when long long is implicitly converted to float).
• 1) Built-in functions
2) User-defined functions