Skip to content

Latest commit

 

History

History
19 lines (16 loc) · 1.79 KB

Cpp.md

File metadata and controls

19 lines (16 loc) · 1.79 KB

C++

Method Defintion
\n newline
cout<<value_to_print<<value_to_print; print
printf("%s", string); printf(string); print
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);

Data Types

  • 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