user81351: (Im new to the arduino side of stackexchange). Im working on a worksheet for to begin with arduino. I have prior experiences working with arduinos, but problem is new for my field of expertise. Any help will be well appreciated (need help pls uwu)
Problem statement:

I tried different methods to obtain those values, but all are to vain.
Methods that I tried so far:

using limits.h, floats.h and inbuild variables of those library -- Problem: Im getting wrong minimum and maximum values for float and double: 
Code:

#include <stdio.h>
#include <limits.h>
#include <float.h>
#include <math.h>

char fltmax[250];
char fltmin[250];
char dblmax[250];
char dblmin[250];

void sint() {
  Serial.print("Range of signed int: ");
  Serial.print(INT_MIN);
  Serial.print(" to ");
  Serial.print(INT_MAX);
  Serial.print(", which has a storage size of ");
  Serial.print(sizeof(int));
  Serial.println(" bytes");
}
void usint() {
  Serial.print("Range of unsigned int: 0 to ");
  Serial.print(UINT_MAX);
  Serial.print(", which has a storage size of ");
  Serial.print(sizeof(unsigned int));
  Serial.println(" bytes");
}
void schar() {
  Serial.print("Range of signed char: ");
  Serial.print(SCHAR_MIN);
  Serial.print(" to ");
  Serial.print(SCHAR_MAX);
  Serial.print(", which has a storage size of ");
  Serial.print(sizeof(signed char));
  Serial.println(" bytes");
}
void uschar() {
  Serial.print("Range of unsigned char: 0 to ");
  Serial.print(UCHAR_MAX);
  Serial.print(", which has a storage size of ");
  Serial.print(sizeof(unsigned char));
  Serial.println(" bytes");
}
void slong() {
  Serial.print("Range of signed long: ");
  Serial.print(LONG_MIN);
  Serial.print(" to ");
  Serial.print(LONG_MAX);
  Serial.print(", which has a storage size of ");
  Serial.print(sizeof(signed long));
  Serial.println(" bytes");
}
void uslong() {
  Serial.print("Range of unsigned long: 0 to ");
  Serial.print(ULONG_MAX);
  Serial.print(", which has a storage size of ");
  Serial.print(sizeof(unsigned long));
  Serial.println(" bytes");
}
void sshort() {
  Serial.print("Range of signed short: ");
  Serial.print(SHRT_MIN);
  Serial.print(" to ");
  Serial.print(SHRT_MAX);
  Serial.print(", which has a storage size of ");
  Serial.print(sizeof(signed short));
  Serial.println(" bytes");
}
void usshort() {
  Serial.print("Range of unsigned long: 0 to ");
  Serial.print(USHRT_MAX);
  Serial.print(", which has a storage size of ");
  Serial.print(sizeof(unsigned short));
  Serial.println(" bytes");
}
void flt() {
  Serial.print("Range of float: ");
  dtostrf(FLT_MIN, -1, 50, fltmin);
  Serial.print(fltmin);
  Serial.print(" to ");
  sprintf(fltmax,"%e", FLT_MAX);
  puts(fltmax);
  Serial.print(", which has a storage size of ");
  Serial.print(sizeof(float));
  Serial.println(" bytes");
}
void dbl() {
  Serial.print("Range of double: ");
  dtostrf(DBL_MIN, -1, 50, dblmin);
  Serial.print(dblmin);
  Serial.print(" to ");
  dtostrf(DBL_MAX, -1, 0, dblmax);
  Serial.print(dblmax);
  Serial.print(", which has a storage size of ");
  Serial.print(sizeof(double));
  Serial.println(" bytes");
}


void setup() {
  Serial.begin(115200);
  sint();
  usint();
  schar();
  uschar();
  slong();
  uslong();
  sshort();
  usshort();
  flt();
  dbl();
}


void loop() {
}


Other than using dtostrf(), I found better alternatives at exchange here too such as: Print unsigned long long in ESP8266 and https://www.tutorialspoint.com/c_standard_library/c_function_sprintf.htm

I tried combining both where the test code that I used before actual implementation:
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <float.h>
#include <limits.h>



void setup () {
  char str[30];
  Serial.begin(115200);
  snprintf(str, 30, "Value of float max = %e", FLT_MAX);
  /*puts(str);*/
  Serial.print(str);
  return(0);
}
void loop(){
  
}

But puts(str) is not getting printed in the serial monitor.  Then It clicked, that I have to use Serial.(code) for it to get printed in serial monitor, but it ended up in Serial.puts(str) code not found. Then I tried just Serial.print(str), but it just outputs Value of float max = ? (Initially, before I wrote this problem here, it output Va only, which i have no idea how it changed, but its still wrong). What do I do now? also, Why cant I use puts to print in serial monitor?
The board im using for this is Arduino UNO (ATmega328P)

user7508: There are two issues here.
One is that the Arduino core uses Serial to handle serial I/O, rather
than the traditional libc interface (printf(), puts() and co.). The
avr-libc does provide the traditional stdio functions, but these will
not work unless you tell them where stdout is, which is a bit complex.
The take away is to just use the methods of Serial for accessing the
serial port.
Then there is the question: why did it print “Value of float max = ?”.
The reason is that the avr-libc does not provide by default support for
formatting floating point numbers with sprintf(). That support is
quite expensive in flash space, and it is omitted unless you link with a
specific version of the avr-libc. The simple workarounds are:

Use Serial.print() to both format and print floating point numbers,
which is inconvenient for very small or very large numbers.
Use dtostre() or dtostrf() to format them.

In your case, dtostre() is a better fit:
void setup() {
    char val[40];
    Serial.begin(9600);
    Serial.print("Range of float: ");
    dtostre(FLT_MIN, val, 5, 0);
    Serial.print(val);
    Serial.print(" to ");
    dtostre(FLT_MAX, val, 5, 0);
    Serial.print(val);
    Serial.println();
}

void loop(){}

prints:
Range of float: 1.17549e-38 to 3.40282e+38


81351: <p>(Im new to the arduino side of stackexchange). Im working on a worksheet for to begin with arduino. I have prior experiences working with arduinos, but problem is new for my field of expertise. Any help will be well appreciated (need help pls uwu)</p>
<p>Problem statement:</p>
<p><a href="https://i.stack.imgur.com/OihAW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OihAW.png" alt="Problem statement" /></a></p>
<p>I tried different methods to obtain those values, but all are to vain.</p>
<p>Methods that I tried so far:</p>
<ul>
<li>using limits.h, floats.h and inbuild variables of those library -- Problem: Im getting wrong minimum and maximum values for float and double: <a href="https://i.stack.imgur.com/3gDVU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3gDVU.png" alt="Wrong output" /></a>
Code:</li>
</ul>
<pre><code>#include &lt;stdio.h&gt;
#include &lt;limits.h&gt;
#include &lt;float.h&gt;
#include &lt;math.h&gt;

char fltmax[250];
char fltmin[250];
char dblmax[250];
char dblmin[250];

void sint() {
  Serial.print(&quot;Range of signed int: &quot;);
  Serial.print(INT_MIN);
  Serial.print(&quot; to &quot;);
  Serial.print(INT_MAX);
  Serial.print(&quot;, which has a storage size of &quot;);
  Serial.print(sizeof(int));
  Serial.println(&quot; bytes&quot;);
}
void usint() {
  Serial.print(&quot;Range of unsigned int: 0 to &quot;);
  Serial.print(UINT_MAX);
  Serial.print(&quot;, which has a storage size of &quot;);
  Serial.print(sizeof(unsigned int));
  Serial.println(&quot; bytes&quot;);
}
void schar() {
  Serial.print(&quot;Range of signed char: &quot;);
  Serial.print(SCHAR_MIN);
  Serial.print(&quot; to &quot;);
  Serial.print(SCHAR_MAX);
  Serial.print(&quot;, which has a storage size of &quot;);
  Serial.print(sizeof(signed char));
  Serial.println(&quot; bytes&quot;);
}
void uschar() {
  Serial.print(&quot;Range of unsigned char: 0 to &quot;);
  Serial.print(UCHAR_MAX);
  Serial.print(&quot;, which has a storage size of &quot;);
  Serial.print(sizeof(unsigned char));
  Serial.println(&quot; bytes&quot;);
}
void slong() {
  Serial.print(&quot;Range of signed long: &quot;);
  Serial.print(LONG_MIN);
  Serial.print(&quot; to &quot;);
  Serial.print(LONG_MAX);
  Serial.print(&quot;, which has a storage size of &quot;);
  Serial.print(sizeof(signed long));
  Serial.println(&quot; bytes&quot;);
}
void uslong() {
  Serial.print(&quot;Range of unsigned long: 0 to &quot;);
  Serial.print(ULONG_MAX);
  Serial.print(&quot;, which has a storage size of &quot;);
  Serial.print(sizeof(unsigned long));
  Serial.println(&quot; bytes&quot;);
}
void sshort() {
  Serial.print(&quot;Range of signed short: &quot;);
  Serial.print(SHRT_MIN);
  Serial.print(&quot; to &quot;);
  Serial.print(SHRT_MAX);
  Serial.print(&quot;, which has a storage size of &quot;);
  Serial.print(sizeof(signed short));
  Serial.println(&quot; bytes&quot;);
}
void usshort() {
  Serial.print(&quot;Range of unsigned long: 0 to &quot;);
  Serial.print(USHRT_MAX);
  Serial.print(&quot;, which has a storage size of &quot;);
  Serial.print(sizeof(unsigned short));
  Serial.println(&quot; bytes&quot;);
}
void flt() {
  Serial.print(&quot;Range of float: &quot;);
  dtostrf(FLT_MIN, -1, 50, fltmin);
  Serial.print(fltmin);
  Serial.print(&quot; to &quot;);
  sprintf(fltmax,&quot;%e&quot;, FLT_MAX);
  puts(fltmax);
  Serial.print(&quot;, which has a storage size of &quot;);
  Serial.print(sizeof(float));
  Serial.println(&quot; bytes&quot;);
}
void dbl() {
  Serial.print(&quot;Range of double: &quot;);
  dtostrf(DBL_MIN, -1, 50, dblmin);
  Serial.print(dblmin);
  Serial.print(&quot; to &quot;);
  dtostrf(DBL_MAX, -1, 0, dblmax);
  Serial.print(dblmax);
  Serial.print(&quot;, which has a storage size of &quot;);
  Serial.print(sizeof(double));
  Serial.println(&quot; bytes&quot;);
}


void setup() {
  Serial.begin(115200);
  sint();
  usint();
  schar();
  uschar();
  slong();
  uslong();
  sshort();
  usshort();
  flt();
  dbl();
}


void loop() {
}
</code></pre>
<ul>
<li>Other than using dtostrf(), I found better alternatives at exchange here too such as: <a href="https://arduino.stackexchange.com/questions/65813/print-unsigned-long-long-in-esp8266">Print unsigned long long in ESP8266</a> and <a href="https://www.tutorialspoint.com/c_standard_library/c_function_sprintf.htm" rel="nofollow noreferrer">https://www.tutorialspoint.com/c_standard_library/c_function_sprintf.htm</a></li>
</ul>
<p>I tried combining both where the test code that I used before actual implementation:</p>
<pre><code>#include &lt;stdio.h&gt;
#include &lt;math.h&gt;
#include &lt;string.h&gt;
#include &lt;float.h&gt;
#include &lt;limits.h&gt;



void setup () {
  char str[30];
  Serial.begin(115200);
  snprintf(str, 30, &quot;Value of float max = %e&quot;, FLT_MAX);
  /*puts(str);*/
  Serial.print(str);
  return(0);
}
void loop(){
  
}
</code></pre>
<p>But <code>puts(str)</code> is not getting printed in the serial monitor.  Then It clicked, that I have to use Serial.(code) for it to get printed in serial monitor, but it ended up in <code>Serial.puts(str)</code> code not found. Then I tried just <code>Serial.print(str)</code>, but it just outputs <code>Value of float max = ?</code> (Initially, before I wrote this problem here, it output <code>Va</code> only, which i have no idea how it changed, but its still wrong). What do I do now? also, Why cant I use puts to print in serial monitor?</p>
<p>The board im using for this is Arduino UNO (ATmega328P)</p>
 7508: <p>There are two issues here.</p>
<p>One is that the Arduino core uses <code>Serial</code> to handle serial I/O, rather
than the traditional libc interface (<code>printf()</code>, <code>puts()</code> and co.). The
avr-libc does provide the traditional stdio functions, but these will
not work unless you tell them where <code>stdout</code> is, which is a bit complex.</p>
<p>The take away is to just use the methods of <code>Serial</code> for accessing the
serial port.</p>
<p>Then there is the question: why did it print “Value of float max = ?”.
The reason is that the avr-libc does not provide by default support for
formatting floating point numbers with <code>sprintf()</code>. That support is
quite expensive in flash space, and it is omitted unless you link with a
specific version of the avr-libc. The simple workarounds are:</p>
<ul>
<li>Use <code>Serial.print()</code> to both format and print floating point numbers,
which is inconvenient for very small or very large numbers.</li>
<li>Use <a href="https://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#amgrp67796e0946dab291b611cb32584a051f" rel="nofollow noreferrer"><code>dtostre()</code> or <code>dtostrf()</code></a> to format them.</li>
</ul>
<p>In your case, <code>dtostre()</code> is a better fit:</p>
<pre class="lang-cpp prettyprint-override"><code>void setup() {
    char val[40];
    Serial.begin(9600);
    Serial.print(&quot;Range of float: &quot;);
    dtostre(FLT_MIN, val, 5, 0);
    Serial.print(val);
    Serial.print(&quot; to &quot;);
    dtostre(FLT_MAX, val, 5, 0);
    Serial.print(val);
    Serial.println();
}

void loop(){}
</code></pre>
<p>prints:</p>
<pre><code>Range of float: 1.17549e-38 to 3.40282e+38
</code></pre>
