शुरू करेंमुफ़्त में शुरू करें

Print to the console

You can use Rprintf() to print formatted output to the console. It is similar to the sprintf() function in R, and uses the format specifiers:

  • %d to specify an integer
  • %s to specify a string

यह अभ्यास पाठ्यक्रम का हिस्सा है

Optimizing R Code with Rcpp

पाठ्यक्रम देखें

अभ्यास निर्देश

Write a function that adds two integers (x and y) and prints the following message about it:

** <x> + <y> = <x + y>

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Define the function add()
cppFunction('
  int add(int x, int y) {
    int res = x + y ;
    ___("** %d + ___ = ___\\n", x, y, res) ;
    return res ;
  }
')

# Call add() to print THE answer
add(40, 2)
कोड संपादित करें और चलाएँ