0% found this document useful (0 votes)
24 views

Hello-0.c David J. Malan Malan@harvard - Edu Says Hello To The World. Demonstrates Use of Printf.

This document contains code for three programs that say hello. The first program prints "hello, world" and demonstrates printf. The second program prints "hello, David" and demonstrates using CS50's library. The third program prompts the user for their name, stores it as a string, and prints "hello, {name}" demonstrating GetString from CS50's library and standard input.

Uploaded by

JamesKJaak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Hello-0.c David J. Malan Malan@harvard - Edu Says Hello To The World. Demonstrates Use of Printf.

This document contains code for three programs that say hello. The first program prints "hello, world" and demonstrates printf. The second program prints "hello, David" and demonstrates using CS50's library. The third program prompts the user for their name, stores it as a string, and prints "hello, {name}" demonstrating GetString from CS50's library and standard input.

Uploaded by

JamesKJaak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

lectures/1/m/src1m/hello-0.

c
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.

/**
* hello-0.c
*
* David J. Malan
* [email protected]
*
* Says hello to the world.
*
* Demonstrates use of printf.
*/
#include <stdio.h>
int main(void)
{
printf("hello, world\n");
}

lectures/1/m/src1m/hello-1.c
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.

/**
* hello-1.c
*
* David J. Malan
* [email protected]
*
* Says hello to just David.
*
* Demonstrates use of CS50's library.
*/
#include <cs50.h>
#include <stdio.h>
int main(void)
{
string name = "David";
printf("hello, %s\n", name);
}

lectures/1/m/src1m/hello-2.c
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.

/**
* hello-2.c
*
* David J. Malan
* [email protected]
*
* Says hello to whomever.
*
* Demonstrates use of CS50's library and standard input.
*/
#include <cs50.h>
#include <stdio.h>
int main(void)
{
printf("State your name: ");
string name = GetString();
printf("hello, %s\n", name);
}

You might also like