0% found this document useful (0 votes)
21 views6 pages

What Is C

C is a general-purpose programming language created in 1972 by Dennis Ritchie at Bell Labs. It is versatile and can be used to create many different types of software applications. The syntax of C code includes using header files like stdio.h, which provide functions like printf() for output. A basic C program structure includes int main(), which acts as a container enclosing the main code block between curly brackets. This container holds the program instructions, like printing "Hello World!".

Uploaded by

Aditya Pandey
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)
21 views6 pages

What Is C

C is a general-purpose programming language created in 1972 by Dennis Ritchie at Bell Labs. It is versatile and can be used to create many different types of software applications. The syntax of C code includes using header files like stdio.h, which provide functions like printf() for output. A basic C program structure includes int main(), which acts as a container enclosing the main code block between curly brackets. This container holds the program instructions, like printing "Hello World!".

Uploaded by

Aditya Pandey
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/ 6

What is C ?

C is a general-purpose programming language created by


Dennis Ritchie at the Bell Laboratories in 1972. It is a very
popular language, despite being old.

Now u may ask what's "general-purpose" ?

Well when we say general-purpose it means that this


language is capable of doing many different things or tasks.
It is versatile and not limited to a single task. This language
has so many tools and features by using which programmers
can create different types of softwares such as website,
apps, games, etc.

Why learn C ?
One of the most popular programming language in the
world
If you know C, you will have no problem learning other
popular programming languages such as Java, Python,
C++, C#, etc.
C is very fast, compared to other programming
languages, like Java and Python
C is very versatile; it can be used in both applications and
technolgies
Syntax of C
Syntax refers to the set of rules and guidelines that
define the structure and format of a programming
language. It determines how the code should be written
in order for it to be valid and understandable by the
computer.

#include <stdio.h>

int main() {
printf("Hello World!");
return 0;
}

This is the basic structure or syntax of C language

Line 1: #include <stdio.h> is a header file library that lets us


work with input and output functions, such as printf() (used in
line 4). Header files add functionality to C programs.

Just think of it as something that (almost) always appears in


your program.

Line 2: A blank line. C ignores white space. But we use it to


make the code more readable.

Line 3: Another thing that always appear in a C program, is


main(). This is called a function. Any code inside its curly
brackets {} will be executed.
Line 4: printf() is a function used to output/print text to the
screen. In our example it will output "Hello World!".

Note that :
1. Every C statement ends with a semicolon ;

2. The body of int main() could also been written


as:
int main() {printf("Hello World!"); return 0; }

We just provide whitespaces to make the code


neat and more readable.

Line 5: return 0 ends the main() function

Line 6: Do not forget to add the closing curly bracket } to


actually end the main function.

Ouput of the program :


Hello World!

Still confused ? Let's try to explain more simply...

#include <studio.h>
#include <stdio.h> tells the computer to include (or bring in)
a special file called "stdio.h". This file contains some useful
functions which are used in the program.
"stdio.h" is like a special toolbox for programmers. It has all
the tools needed to communicate with the computer when
we write programs.

Inside stdio.h, there are functions that have special powers.


These functions are like little helpers that follow specific
instructions to do tasks for us.

It's like using a remote control to turn on the TV. We don't


need to understand how the TV works inside, we just need to
know how to press the buttons.

Just like you can control the TV using different buttons on


the remote control, stdio.h provides us with different
functions that we can use to control the computer. We can
show messages, get input from the user, and perform other
actions by using the appropriate functions from stdio.h.

So, stdio.h works like a remote control for the computer, with
different buttons (functions) that send signals to the
computer (like showing messages on the screen) based on the
instructions it holds. It helps us interact with the computer
and make things happen in our programs, just like a remote
control helps us control the TV.

That's the reason why we include stdio.h in our program.


int main () { }
Imagine you are playing with building blocks, and you have a
special container called "main." This container is where you
will put all the instructions for your game.

In our example code, "int main() {}" is like that special


container. The word "int" stands for "integer," which means a
whole number. It's like a box where we can store a number.

The word "main" is the name of the container. It's like giving a
name to your special building block container. You can call it
"main" or any other name you like.

The parentheses "()" are like the opening and closing of the
container. They show that everything we put inside these
parentheses will be part of our special container.

Finally, the curly braces "{}" are like the walls of our
container. They enclose the instructions and keep them
together.

So, when we write "int main() {}", we are creating a special


container called "main" that can hold our instructions for the
game.

Inside those curly braces "{}", we put the specific instructions


for our game. In this example, we have the line printf("Hello
World!");, which tells the computer to show the message
"Hello World!" on the screen.
After the instructions are written inside the main container,
we use the line return 0;. It's like saying, "We are finished with
the game, and everything went well." The number 0 means
everything is okay, and the game can finish running the
program.

So, to summarize, "int main() {}" is like a special container with


a name "main" that holds our instructions for the game. We
put the specific actions we want the computer to do inside
this container, and it follows those instructions to play the
game.

You might also like