Professional Documents
Culture Documents
Week two Arrays
Week two Arrays
Week two Arrays
#include <cs50.h>
#include <stdio.h>
int main(void)
{
string name = get_string ("what's your name? ");
printf("hello, %\n", name); (make hello =
clang -o hello hello.c -lcs50);
}
=) Qua trinh xu ly giu lieu ben trong may tinh: Xu ly he nhi phan de may tinh hieu
duoc ngon ngu.
1. Preprocessing
2. Compiling
3. Assembling
4. Linking
Fix bug
$ debug50 ./buggy0
looks like you've changed your code. Recompile and then re-run debug5
=)
$ make buggy0
$ debug50 ./buggy0
Arrays
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int scores[3]
for (int i = 0; i < 3; i++)
{
scores[i] = get_int("scores: ");
}
int main(void)
{
Char a = "H";
Char b = "I";
Char c = "!";
printf(% % %\n; a, b, c); (%i %i %i\n, a, b ,c) =) $make hi_ $./hi $ 72 73
33_$ (%i is the number of type)
}
TERMINAL
$ make hi
$ ./hi
HI!
$
String:
#include <cs50.h>
#include <stdio.h>
int main(void)
{
string s = "HI!"'; or string words[2];
string t = "BYE!"; words[0] = "HI!";
words[1] = "BYE!";
printf("%s\n", s); printf("%s\n", words[0]);
printf("%s\n", t); printf("%s\n", words[1]);
}
TERMINAL
$ make hi
$ ./hi
HI!
BYE!
$
int main(void)
{
string name = get_string("what's your name? ");
int n = strlen(name);
printf("%i\n", n);
}
TERMINAL
$ make length
$ ./length
$ what's your name? David
$ 5 (this is the sentence of David )
$
int main(void)
{
string s = get_string("Before: ");
printf("After: ");
for (int i = 0; i < strlen(s); i++);
{
if (s[i] >= 'a' && s[i] <= 'z') or if (islower(s[i]));
{
printf("%c", s[i] - 32); or printf("%c", toupper(s[i])); =) this distance
of A to a is 32 bit = 8 byte
}
else
{
printf("%c", s[i]);
}
printf("\n");
}
=) Do faster more than: use only printf("%c", toupper(s[i])); and you have
wonderful result. Everything now you just
understand why? program this here? why?... just understand why?
}
Okay tonight we study to here! Good job man! See you a later! Good night! Thanks
you.
(*) GREET C
#include <cs50.h>
#include <stdio.h>
#include <cs50.h>
#include <stdio.h>
(*) ECHO $?
(+) CRYPTOGRAPHY this is the code for hidden or secret messenger
(+) ENCRYPTION nt
(+) DECRYPTION nt