The basic in C programming With full detail description

basic-in-c-programming

C is a general-purpose programming language, which was designed by Dennis Ritchie in 1972 and C is not a very high-level language

It will be little difficult to understand C if we compare with a high-level language like python, and suppose, if you are planning to learn C++, C#, and Java it is better to learn C first

C++, C#, and Java are based on C.

Writing a program in C

Rendered by QuickLaTeX.com

Standard header files

Rendered by QuickLaTeX.com

Structure of a C program

Main( )
{
            Statement 1;
             .......
             .....n;
}
Function 1( )
{
            Statement 1;
             .........
             .......n;
}
Function 2( )
{
              Statement1;
              .......
               ....n;
}
Function N( )
{
              Statement 1;
              ..........
               .......n;
}

Writing a simple C program

Return 0

The integer value return by main() function indicates success in compiling the given code

Return a non zero

if the main() function fail to do its intended work. next, it return’s a non-zero number, that indicates failure in compiling the given code

Statement terminator

every statement you write with  c program must be terminated with a semicolon(;)

Rendered by QuickLaTeX.com

Input and output function

Scanf () function receives input values and printf() function print output values on the screen

Syntax of a printf() function

Printf("<format string>",<no of  variables>);

<format string> contain

Int uses %d
Float uses %f
Char uses %c
Character string uses %s

Example

Printf("%d", x);
scanf("%f%f%d",&x,&y,&z);

We use scanf() to receive input values from user

Example

Scanf("%d",&x);
printf("%f%f%d", x,y,z);

Note: the difference between printf() and scanf() function

use address operator(&) in front of variable for scanf() function

What is a  main()  in c program?

It is a function, which you can consider as a vessel with a set of statements in it.

Int main()
{
Statement1;
...................
..................n;
}

The datatype int kept in front of main() function to return an integer number

How to comment in a c program?

Comments in a c program must be enclosed within asterisk(*)

/* this is a comment*/

Related posts

Mohammed Anees

Hey there, welcome to aneescraftsmanship I am Mohammed Anees an independent developer/blogger. I like to share and discuss the craft with others plus the things which I have learned because I believe that through discussion and sharing a new world opens up

Leave a Reply

Your email address will not be published.