knowledgediarybd.com

Your Virtual Knowledge Campus







Fundamental Of C Programming

introduction of c,fundamental of c Fundamental Of C

C is one of the most important and powerful programming language. Dennis, an American computer scientist was developed C in 1973 at AT&T Bell Labs.

Later many languages (like C++, Java, JavaScript, PHP, C#, D) are developed from C directly or indirectly.

Many compilers are also developed by using it. C is marked as one of the most useful programming language of all time.

Setting up a compiler — Very first work:

For using any programming language, setting up a compiler is first work. Compiler is that by which a written programming code turns into executable that a computer can run and show us the output.

There are many compilers for C. Code blocks (www.codeblocks.org), an open source compiler, may be a suitable chooses among them or you can also download Turbo C Compiler form here. It can run under Windows, Linux as well as Mac.

Starting with  C:

Basic Format of  c program.

main()             > Function name
{                          >Start of program here
—————
—————         >Program statement here
—————

}                          > End of program

Example of C  Programming:

A C program consists of some block of code. The important block is “main()” function block. It is a must for every code written in C.The other functions are controlled from this function. A basic C program is like this:

#include<stdio.h>
int main()
{
printf("Well come to C tutorials.");
return 0;
}

Description of the above c program code:

1. The program is started by “#include”, a processor directive which is used to tell compiler to put code from header to program before executing the code.A header is used to access various functions of C.

2. The header stdio.h contains the information of printf() and scanf() function.

3.Then  main() function is used. Every function in C starts and ends with two curly braces ( {…} ). Not only functions but also any block of C start and end with curly braces. The curly braces hold our written code in main function.

4. Before main()  function a word “int” is used which tells us this function is returning a integer value (it is illustrated in functions section of this site).

5. The printf() function in curly braces is used to print something.After executing this program, “Welcome to C tutorial” will be seen in display.

6. One of the important parts of C built in function is semicolon (;) which is used at the end of the function. If semicolon is not used, an error will be shown in the display.

7. Next command of the program is return 0 (illustrated in function section). This means that the main function does not return any value.

 Finally compile the code using compile button to check error. Then using the compiler’s build button, make the program executable and then run it.

 

The output of above code is:

Well come to C tutorials.

Some Easy Problem written in C are given below

#A program that read a numbers and display  following shape:

1
11
111
1111
11111
111111
1111111
11111111
111111111
1111111111
11111111111
111111111111
1111111111111
11111111111111
111111111111111

#include<stdio.h>
#include<conio.h>
int main()
{

int a=1,b,c,n;
printf("Enter the value of n:");
scanf("%d",&n);
while(a<=n)
{
b=1;
while(b<=a)
{
b++;
printf("1");

}
printf("\n");
a++;
}
getch();
return 0;
}

#A program that read two integer and display summation, subtraction, multiplication.

#A program that read two integer and display Division & Remainder.

#A program that read any character and display ASCII value.

#A program that read lower case character and display in Upper case.

#A program that read any upper case character and display in Lower case.

 

Related Post Or  you may felt interest:

  1. Turbo C Compiler Download & Installing

  2. Variable In C

  3. Data Types In C

  4. Token in c

  5. C Operators,Operands and expression

  6. If, Else If..Else & Switch Statement

  7. For loop while loop and Do while loop in C

  8. Continue and Break Statement In C

knowledgediarybd.com © 2017
shares