Thomas
5
Q:

printf in c++

#include <iostream>

int main() {
  std::cout << "Hello, World!"; // prints 'Hello, World!' to the output.
  return 0;
}
8
#include <iostream>
using namespace std;

int main(){
  cout<<"Hello World!"<< endl; // prints "Hello World"
  return 0;
}
3
#include <cstdio>

int main()
{
    char ch = 'a';
    float a = 5.0, b = 3.0;
    int x = 10;

    printf("%.3f / %.3f = %.3f \n", a,b,a/b);
    printf("Setting width %*c \n",5,ch);
    printf("Octal equivalent of %d is %o \n",x,x);

    return 0;
}
1
/* printf example */
#include <stdio.h>

int main()
{
   printf ("Characters: %c %c \n", 'a', 65);
   printf ("Decimals: %d %ld\n", 1977, 650000L);
   printf ("Preceding with blanks: %10d \n", 1977);
   printf ("Preceding with zeros: %010d \n", 1977);
   printf ("Some different radices: %d %x %o %#x %#o \n", 100, 100, 100, 100, 100);
   printf ("floats: %4.2f %+.0e %E \n", 3.1416, 3.1416, 3.1416);
   printf ("Width trick: %*d \n", 5, 10);
   printf ("%s \n", "A string");
   return 0;
}
2
#include <iostream>

int main() {
  std::cout << "Hello World!"; //cout keyword prints "Hello World!"
  return 0;
}
0

New to Communities?

Join the community