C bootcamp · Lab 49

Greet by name

easyStrings8 minLesson: Strings

Read the question, write C on the right, then Run or Check.

QuestionHint and solution stay closed until you open them

Read a single word name and print Hello, <name>!

Input. One word.

Output. Hello, name!

Examples

Example 1
Input
Ada
Output
Hello, Ada!
Example 2
Input
World
Output
Hello, World!
Hint
  1. printf("Hello, %s!\n", name);
Show correct code

Peek only after you have tried. You can still Check your own version.

#include <stdio.h>

int main(void) {
  char name[64];
  if (scanf("%63s", name) != 1) return 1;
  printf("Hello, %s!\n", name);
  return 0;
}
main.cC17 · gcc · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.