C programming

                       A program is a set of instructions that a computer follows in order to perform a specific task. There are different types of programming languages such as BASIC, Pascal, C, Java, Ruby, Python, etc...On this site, we will see about the C program.


                     C is a general-purpose, procedural computer programming language. It is an ANSI/ISO standard and powerful programming language for developing real-time applications. It was invented by Dennis Ritchie at the bell laboratories in 1972. It is the most widely used language and it is the basic for all programming languages, all other programming languages were directly (or) indirectly derived from C.

C provides,

* Efficiency : intended for applications where assembly language had traditionally been used.

* Portability : small and easily written

* Power : large collection of data types and operators

* Flexibility : not only for the system but also for embedded system commercial data processing.

*Standard library.

* Integration with UNIX.

C is used in,
           
            Operating systems, language operators, assemblers, text editors, print spoolers, network drivers, Morden programs, databases, language interpreters, utilities.

Problems with languages existing before c,
     
              * They were categorized in low-level languages and high-level languages.

              * The low-level languages were designed to give better machine efficiency, i.e, faster program execution.

              * The high-level languages were designed to give better programming efficiency, i.e, faster program development.

              * The languages before c were application-specific. For example, FORTRAN (FORmula TRANsalation) was built for engineering application development and COBOL (COmmon Business Oriented Language) was developed for commercial application development.

Rules for writing a c program:

* Each instruction in the c program is written as a separate statement.

* The statements in the program must appear in the same order in which we wish them to be executed unless the logic of the program demands a deliberate jump or transfer of control to a statement that is out of sequence.

* Blank spaces may be inserted between two words to improve the readability of the statement.

* All syntax should be entered in small case letters.

* Every c statement must end with a ( ; ) thus  ( ; ) act as a Statement terminator.

* There is no specific rule for the position at which the statement is to be written. that's why it is often called a free-form language.

 we are going to see how to write a simple program using a C programming language as well as we are going to see some basic definitions. suppose if your a beginner in programing language you have to know that some definition, you didn't know that some definition you couldn't write the program.so now in this site first we focus to learn some data types and some related concepts we are going to see now.



data types:
  
 which means how we enter the data on your computer. then the basic level of our data type is,
  • int (integer a whole number)
  • float(floating point a number which is a fractional point)
  • double(double precision floating point)
  • char(single character)
then, these are the data types.
some statements are here in a C language like a printf(),scanf(),clrscr(),sizeof()...etc.
 then, no we will see how to write a basic level program using the above contents.

write the c program to print the "hello world"
 

 #include<stdio.h>                     

 #include<conio.h>

 void main()       

 {

  

    printf("hello world");

    getch();

  }

                                                  

 

 

 
 output
 hello world                



this the output of our program.
now how its execute our program we will see above the contents


#include<stdio.h> - its called header file "stdio.h" standard file
int main() -its the main function its contains int data type only, you cant store any float or something .when you using the main function any place you should put curly brackets {},
then next you should write your code.
printf()- which means it is print your value.


return 0- return the value of your program

one thing you should know that when you using int main()
At that time you have to put return value on your insides curly bracket.
some times we are using void main().
void main()-void main which means we can give any data types in your program. because it contains an only empty value. you can give any value.
when you using void main() in the last statement you should give getch();
getch(); - getch means it gives your output on your console suppose if you didn't give getch(); at the last of ur statement your program won't run, if your program has right also its will not give your program output.


some basic important syntax :

       













 


these are the basic syntax for main startcture.  first be familiar with these sysntax then move further ways


No comments:

Post a Comment