Method | Defintion |
---|---|
\n |
newline |
cout<<value_to_print<<value_to_print; |
|
printf("%s", string); printf(string); |
|
cin >> s >> n; |
This reads the first word from stdin and saves it as string s, then reads the second word from stdin and saves it as integer n |
cout << s << " " << n << endl; |
This code prints the contents of string s, a single space (" "), then the integer n. We end our line of output with a newline using endl. |
scanf(" format_specifier", &val) |
This reads a data type ex: char ch;double d; scanf("%c %lf", &ch, &d); |
printf(" format_specifier", &val) |
This prints a data type ex: char ch = 'd'; double d = 234.432; printf("%c %lf", ch, d); |
- Int ("%d"): 32 Bit integer
- Long ("%ld"): 64 bit integer
- Char ("%c"): Character type
- Float ("%f"): 32 bit real value
- Double ("%lf"): 64 bit real value