Anasayfa » C / C++

C / C++ Courses ? 2 (Output, Escape Characters & Comments)

22 Temmuz 2010 1.505 views Yorum Yok

Let’s continue to refresh our minds:

The first function that we should know is printf function..

This function is used for output. The usage of this function is so simple.

Whatever you want to write as output on the screen, you can put this between quotation marks (” “)

printf(” (Things that you want to see on the screen will be here) “);


int main(){

printf ( ” Don’t say hello world anymore! ” ) ;

return 0;


Output will be like that:

Don’t say hello world anymore!

(In the following courses, we will learn functions in details, but now this is enough for us.)

Escape characters:

  • Escape characters are used in only printf statements.
  • The role of them depends on the character after back slash “\”.
  • This back slash means that sth different is going to happen.

\n : cursor moves to next line

\t : (tab) cursor moves 8 spaces

\a : alert

\” : to be able to write (“) on the screen

\\ : to be able to write (\) on the screen

There are more than these, but not used commonly.



int main(){

printf ( ” \nnn\”\\Hey\tn\nn” ) ;

return 0;


Output will be like that:

(empty line)

nn”\Hey        n



  • Comments do not show an output
  • They are not compiled. They are ignored by the compiler, compiler skips this part of program and goes on.
  • They are used to explain the program. Because everyone can do the same program and get the same results but in different ways

For single line comments, we use double slashes “//”

For multiple lines, we put ” /* “ at the beginning of the comment and ” */ “ at the end of it.


int main(){

//This is a single line comment

/* This part

can be

more than one line.

This is for multiple lines.


return 0;


Output of this program is nothing.

Yes, yes.. This is enough for one course. Bye for now!

Take care 🙂

Comments are closed.

Etiketler: , , , , , , , , , ,