Department of Information Technology Introduction Prepared...

Info icon This preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Department of Information Technology Introduction Prepared by: Ms Seetha BIT205- Programming in C++
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Department of Information Technology Introduction to C++ Objectives Objectives The history and evolution of C++. The basic features of the C++ language. The use of some basic C++ features.
Image of page 2
Department of Information Technology Introduction to C++ C++ was developed by Bjagne Stroustrup at AT&T in early 1980s. C++ is based on C and it retains much of that language, including a rich operator set. C++ is a highly portable language, and translators for it exist on many different machines and systems. C++ compilers are highly compatible with the existing C programs because maintaining such compatibility was a design objective.
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Department of Information Technology Introduction to C++ Programming in C++ does not require a graphics environment, and C++ programs do not incur runtime expense from type checking or garbage collection. C++ has improved on C in significant ways, especially in supporting strong typing. The class syntax was added to the language which was an extension of the struct construct in C. C++ is superior than C in supporting object-oriented programming. C++ may even replace C in becoming a general purpose programming language
Image of page 4
Department of Information Technology Introduction to C++ The First C++ Program #include <iostream.h> //this outputs ‘hello world’ to the //terminal using namespace std; int main( ) { cout << “hello world” << endl; return 0; } Preprocessor directives Indicates comment Main function
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Department of Information Technology Introduction to C++ #include <iostream.h> using namespace std; int square(int); //function prototype float average(int,int); //function prototype int main(){ int firstNumber,secondNumber; //local variable declaration cout<<endl; cout <<“Enter an integer between 1 and 200:”); cin >>firstNumber; cout <<“Enter a second integer between 1 and 200:”); cin >>secondNumber; cout << “The Square of “ << firstNumber << “ is” << square(firstNumber) << ‘\n’; cout << “The Square of “ << secondNumber << “ is” << square(secondNumber) << ‘\n’; return 0; }
Image of page 6
Department of Information Technology Introduction to C++ int square (int inNumber){ int squaredResult; squaredresult = inNumber *inNumber; return(squaredResult); } float average (int first, int second){ return((first + second) / 2.0); } Function definition Function definition
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Department of Information Technology Introduction to C++ White Space It is typically used to separate different words in a program. White space consists of one or more space, tab and newline. The judicious use of white space can make your programs much more readable. Comments // and /* .... */ comments in C could be used for representing remarks. Everything on the program line to the right of the // characters (until end of line) is ignored and removed by the preprocessors.
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern