1 / 9

C++

C++. Demonstration. Fundamental of C++. int main() with return 0 void main() without return 0 File name must be .cpp <br> is used between “<br>” <br> means new line endl = End line is used after output redirector &lt;&lt;endl;. Note. #include &lt;iostream.h&gt; #include is pre-processor directive

elinorr
Download Presentation

C++

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. C++ Demonstration

  2. Fundamental of C++ • int main() with return 0 • void main() without return 0 • File name must be .cpp • \n is used between “\n” \n means new line • endl = End line is used after output redirector <<endl;

  3. Note • #include <iostream.h> • #include is pre-processor directive • iostream.h = input output stream (stream refers to the flow of input or output) • << output redirection operator it has to be used after cout object • >> input indirection it is used after cin for example cin>>a; • #include<iostream> using namespace std; (A new standard of C++)

  4. Comment • Line comment \\ • \\ bc stands for beginning counter • Block comment \*comment here*\ \* *\ • Multiple lines of comments between \* and *\

  5. Sample program – hidden characters #include <iostream> using namespace std; int main(){ char University[] = “Phnom Penh International University";//Need to retype char Faculty[]("Computer sciences"); //Need to delete extra space cout << "Welcome to the Student Orientation Program.\n"; cout << "For your studies, we have selected:\n"; cout << "Institution: " << University << "\n"; cout << "Faculty: " << Faculty << "\n"; return 0; }

  6. Celsius to Fahrenheit • c = 5 (f-32)/9 • 9c/5=f-32 • f= 9c/5+32

  7. Palindrome - number • P = 1331, r=0 • When I = 1 • Num = 1331 mod 10 = 1 • P = p/10 = 133 • R= num + (r*10) = 1 • I = 2 • Num=133 mod 10 = 3 • P = p/10=13 • R=num+(r*10) = 13 • i=3 • Num=13 mod 10 = 3 • P=p/10=13/10=1 • R=num+(r*10)=133 • i=4 • Num=1mod 10 = 1 • P=p/10=1/10=0 • R=num+(r*10)=1331

  8. Matrix Product A B C

More Related