Characters counting
Created on May 22, 2024 by Julien Palard
Print the number of characters in the following paragraph:
Ada Lovelace's notes were labelled alphabetically from A to G.
In Note G, she describes an algorithm for the Analytical Engine
to compute Bernoulli numbers.
It is considered to be the first published algorithm ever
specifically tailored for implementation on a computer, and
Ada Lovelace has often been cited as the first computer programmer
for this reason.
I prefilled the answer box with the paragraph as a C string, and
assigned it the name whetting_your_appetite, here it is in case you lost it:
#include <string.h>
#include <stdio.h>
int main(void) {
// I prefilled this variable for you, you don't need to touch it.
const char *whetting_your_appetite = (
"Ada Lovelace's notes were labelled alphabetically from A to G. "
"In Note G, she describes an algorithm for the Analytical Engine "
"to compute Bernoulli numbers. "
"It is considered to be the first published algorithm ever "
"specifically tailored for implementation on a computer, and "
"Ada Lovelace has often been cited as the first computer programmer "
"for this reason."
);
// Enter your code below.
}
Advice
You'll need the strlen function.
How do functions work
A function is a named thing, that take a value (or multiple ones), do something with it, and often give back another value.
A basic example would be the cos function that takes a double
and give back the cosine of it:
cos(0.0)
and it gives back 1.0.
What's given back by a function can be used:
- By storing the given value into a variable.
- By passing the given value directly to another function.
Typically if you want to print the 1.0 from the previous example, you
can either do:
double result = cos(0.0);
printf(".1f\n", result);
or:
printf("%.1f\n", cos(0.0));
There's no corrections yet, hit the `Submit` button to send your code to the correction bot.
Keyboard shortcuts:
- Ctrl-Enter: Send your code to the correction bot.
- Escape: Get back to the instructions tab.