standard input output n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Standard Input - Output PowerPoint Presentation
Download Presentation
Standard Input - Output

Loading in 2 Seconds...

play fullscreen
1 / 25

Standard Input - Output - PowerPoint PPT Presentation


  • 75 Views
  • Uploaded on

Standard Input - Output. By: Muhammad Zidny Naf’an. Output Command. cout() printf() puts() putchar(). cout(). Show the data to screen We must include header file “iostream.h” Ex:. printf(). Function declaration: printf(“string control”, argument1, argument2); Use header header

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Standard Input - Output' - nibaw


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
standard input output

Standard Input - Output

By: Muhammad Zidny Naf’an

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

output command
Output Command
  • cout()
  • printf()
  • puts()
  • putchar()

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

slide3
cout()
  • Show the data to screen
  • We must include header file “iostream.h”
  • Ex:

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

printf
printf()
  • Function declaration:

printf(“string control”, argument1, argument2);

  • Use header header

“stdio.h”

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

printf1
printf()
  • Ex:

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

slide6
puts()
  • Print the string in the screen
  • Use “stdio.h”

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

p utchar
putchar()
  • Print a character to screen

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

manipulation
Manipulation

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

slide9
endl()
  • Insert new line

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

slide10
ends()
  • Insert null character

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

dec oct hex
dec, oct, hex
  • Convert number to decimal, octal, and hexadecimal
  • Use “iomanip.h”

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

setprecission
setprecission()
  • Formatting the number of decimal digit that will showed
  • Use “iomanip.h”

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

setbase base number
setbase(base number)
  • To convert decimal, hexadesimal, and octal.
  • Base number: 10 for decimal, 8 for octal, 16 for hexdecimal

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

setw int width
setw(int width)
  • Set variable’s width in screen
  • User “iomanip.h”

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

setfill char character
setfill(char character)
  • Fill blank from setw with character
  • Use iomanip.h

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

setiosflags
setiosflags()
  • Formatting output
  • Example: Align text in screen (align left or right)
  • Using “iomanip.h”

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

input command
Input Command
  • cin
  • scanf()
  • gets()
  • getch()
  • getche()

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

slide19
cin
  • Without formatting input
  • Use “iostream.h”

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

scanf format setting variable
scanf(“format setting”, &variable)
  • Input data with formatting

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

scanf format setting variable1
scanf(“format setting”, variable)
  • Example:
  • Use “stdio.h”

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

gets char string
gets(char[] string)
  • Input string from keyboard
  • Use “stdio.h”

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

getch
getch()
  • Stands for get character and echo
  • Input one character, and we aren’t need push “enter” button to execute, and character will not be showed in screen
  • Use “conio.h”

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

getch1
getch()
  • Stands for get character and echo
  • Input one character, and we aren’t need push “enter” button to execute, and character will be showed in screen
  • Use “conio.h”

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012

exercise
Exercise
  • Write the program to count average from a student’s score. The are 3 scores.
  • Average Formula = (score1+score2+ score3)/3
  • Input format:
  • Output format:

********** INPUT SCORE *********

Name : <input>

score 1 : <input>

score 2 : <input>

score 3 : <input>

********** AVERAGE SCORE *********

Name : <name>

score 1 : <score1>

score 2 : <score2>

score 3 : <score3>

Average: <average>

Algorithm and Data Structure, UIN Syarif Hidayatullah Jakarta, 2012