1#include <cstdio>
2
3int main()
4{
5 char ch = 'a';
6 float a = 5.0, b = 3.0;
7 int x = 10;
8
9 printf("%.3f / %.3f = %.3f \n", a,b,a/b);
10 printf("Setting width %*c \n",5,ch);
11 printf("Octal equivalent of %d is %o \n",x,x);
12
13 return 0;
14}
1//can't print with printf, since string is a C++ class obj and print %s
2//doesn't recognize
3//can do
4printf("%s", str.c_str()) //converts string to c str (char array)
5
6 //or just use cout<<str;
7
8 //string assignment
9 str1=str2; //or
10str1.assign(str2)