๐Š๐ง๐จ๐ฐ๐ฅ๐ž๐๐ ๐ž ๐ฆ๐ข๐ ๐ก๐ญ ๐›๐ž ๐ฉ๐จ๐ฐ๐ž๐ซ, ๐›๐ฎ๐ญ ๐ข๐ญโ€™๐ฌ ๐ฆ๐ฎ๐œ๐ก ๐ฆ๐จ๐ซ๐ž ๐ฉ๐จ๐ฐ๐ž๐ซ๐Ÿ๐ฎ๐ฅ ๐ฐ๐ก๐ž๐ง ๐ข๐ญโ€™๐ฌ ๐ฌ๐ก๐š๐ซ๐ž๐! with this motto, I am ๐šœ๐š๐šŠ๐š›๐š๐š’๐š—๐š ๐šŠ ๐šœ๐šŽ๐š›๐š’๐šŽ๐šœ ๐š˜๐š ๐šœ๐š‘๐šŠ๐š›๐š’๐š—๐š ๐š–๐šข ๐š”๐š—๐š˜๐š ๐š•๐šŽ๐š๐š๐šŽ ๐š˜๐š ๐š๐š‘๐šŽ ๐™ฒ ๐™ป๐šŠ๐š—๐š๐šž๐šŠ๐š๐šŽ. | Shalu Anand

Post

editor-img
Shalu Anand
Oct 7, 2022

๐Š๐ง๐จ๐ฐ๐ฅ๐ž๐๐ ๐ž ๐ฆ๐ข๐ ๐ก๐ญ ๐›๐ž ๐ฉ๐จ๐ฐ๐ž๐ซ, ๐›๐ฎ๐ญ ๐ข๐ญโ€™๐ฌ ๐ฆ๐ฎ๐œ๐ก ๐ฆ๐จ๐ซ๐ž ๐ฉ๐จ๐ฐ๐ž๐ซ๐Ÿ๐ฎ๐ฅ ๐ฐ๐ก๐ž๐ง ๐ข๐ญโ€™๐ฌ ๐ฌ๐ก๐š๐ซ๐ž๐! with this motto, I am ๐šœ๐š๐šŠ๐š›๐š๐š’๐š—๐š ๐šŠ ๐šœ๐šŽ๐š›๐š’๐šŽ๐šœ ๐š˜๐š ๐šœ๐š‘๐šŠ๐š›๐š’๐š—๐š ๐š–๐šข ๐š”๐š—๐š˜๐š ๐š•๐šŽ๐š๐š๐šŽ ๐š˜๐š ๐š๐š‘๐šŽ ๐™ฒ ๐™ป๐šŠ๐š—๐š๐šž๐šŠ๐š๐šŽ.

๐—Ÿ๐—ฒ๐˜'๐˜€ ๐—•๐—ฒ๐—ด๐—ถ๐—ป

Day 1: Getting started with C Language

media

To create a simple C program that prints "Hello, World" on the screen, use a text editor to create a new file

(e.g. hello.c โ€” the file extension must be .c) containing the following source code:

๐—ต๐—ฒ๐—น๐—น๐—ผ.๐—ฐ

#include <stdio.h>

int main(void)

{

puts("Hello, World");

return 0;

}

๐—Ÿ๐—ฒ๐˜'๐˜€ ๐—น๐—ผ๐—ผ๐—ธ ๐—ฎ๐˜ ๐˜๐—ต๐—ถ๐˜€ ๐˜€๐—ถ๐—บ๐—ฝ๐—น๐—ฒ ๐—ฝ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ ๐—น๐—ถ๐—ป๐—ฒ ๐—ฏ๐˜† ๐—น๐—ถ๐—ป๐—ฒ

#include <stdio.h>

This line tells the compiler to include the contents of the standard library header file stdio.h in the program.

๐—›๐—ฒ๐—ฎ๐—ฑ๐—ฒ๐—ฟ๐˜€ are usually files containing function declarations, macros, and data types, and you must include the header file before you use them. ๐—ง๐—ต๐—ถ๐˜€ ๐—น๐—ถ๐—ป๐—ฒ ๐—ถ๐—ป๐—ฐ๐—น๐˜‚๐—ฑ๐—ฒ๐˜€ ๐˜€๐˜๐—ฑ๐—ถ๐—ผ.๐—ต ๐˜€๐—ผ ๐—ถ๐˜ ๐—ฐ๐—ฎ๐—ป ๐—ฐ๐—ฎ๐—น๐—น ๐˜๐—ต๐—ฒ ๐—ณ๐˜‚๐—ป๐—ฐ๐˜๐—ถ๐—ผ๐—ป ๐—ฝ๐˜‚๐˜๐˜€().

Let's know more about headers.

๐—ถ๐—ป๐˜ ๐—บ๐—ฎ๐—ถ๐—ป(๐˜ƒ๐—ผ๐—ถ๐—ฑ)

This line starts the definition of a function. It states the name of the function (main), the type and number of arguments it expects (void, meaning none), and the type of value that this function returns (int).

๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ ๐—ฒ๐˜…๐—ฒ๐—ฐ๐˜‚๐˜๐—ถ๐—ผ๐—ป ๐˜€๐˜๐—ฎ๐—ฟ๐˜๐˜€ ๐—ถ๐—ป ๐˜๐—ต๐—ฒ ๐—บ๐—ฎ๐—ถ๐—ป() ๐—ณ๐˜‚๐—ป๐—ฐ๐˜๐—ถ๐—ผ๐—ป.

{

...

}

The curly braces are used in pairs to indicate where a block of code begins and ends. They can be used in a lot of ways, but in this case they indicate where the function begins and ends.

๐—ฝ๐˜‚๐˜๐˜€("๐—›๐—ฒ๐—น๐—น๐—ผ, ๐—ช๐—ผ๐—ฟ๐—น๐—ฑ");

This line calls the puts() function to output text to standard output (the screen, by default), followed by a new line.

The string to be output is included within the parentheses.

"Hello, World" is the string that will be written on the screen. In C, ๐—ฒ๐˜ƒ๐—ฒ๐—ฟ๐˜† ๐˜€๐˜๐—ฟ๐—ถ๐—ป๐—ด ๐—น๐—ถ๐˜๐—ฒ๐—ฟ๐—ฎ๐—น ๐˜ƒ๐—ฎ๐—น๐˜‚๐—ฒ ๐—บ๐˜‚๐˜€๐˜ ๐—ฏ๐—ฒ ๐—ถ๐—ป๐˜€๐—ถ๐—ฑ๐—ฒ ๐˜๐—ต๐—ฒ ๐—ฑ๐—ผ๐˜‚๐—ฏ๐—น๐—ฒ ๐—พ๐˜‚๐—ผ๐˜๐—ฒ "...".

In C programs, every statement needs to be terminated by a semi-colon (i.e. ;).

๐—ฟ๐—ฒ๐˜๐˜‚๐—ฟ๐—ป 0;

When we defined main(), we declared it as a function returning an int, meaning it needs to return an integer. In this example, we are returning the integer value 0, which is used to indicate that the program exited successfully.

๐—”๐—ณ๐˜๐—ฒ๐—ฟ ๐˜๐—ต๐—ฒ ๐—ฟ๐—ฒ๐˜๐˜‚๐—ฟ๐—ป 0; ๐˜€๐˜๐—ฎ๐˜๐—ฒ๐—บ๐—ฒ๐—ป๐˜, ๐˜๐—ต๐—ฒ ๐—ฒ๐˜…๐—ฒ๐—ฐ๐˜‚๐˜๐—ถ๐—ผ๐—ป ๐—ฝ๐—ฟ๐—ผ๐—ฐ๐—ฒ๐˜€๐˜€ ๐˜„๐—ถ๐—น๐—น ๐˜๐—ฒ๐—ฟ๐—บ๐—ถ๐—ป๐—ฎ๐˜๐—ฒ.

follow Shalu Anand for more :)