Wednesday, 9 May 2012

UNIX AND C LANGUAGE, TURBO C AND UNIX, HOW TO MAKE C FILES IN UNIX

  1. EDITORS USED IN UNIX / LINUX : Mainly we use   :   vi  Editor    and    ed Editor   to type  a c program in UNIX or LINUX etc.
    .
  2. COMMAND PROMPT AND COMMAND : There are two method(s) to make a C Program in UNIX / LINUX :
          1. -   cat>  <file_name)
          2. -  vi <file_name>  
    Some File Name Examples : like :   AABC.c  hello.c, school.c etc. etc.
    .

Sunday, 6 May 2012

ABOUT MAIN FUNCTION IN C LANGUAGE [What is void main(), int main(), char main(), main()], What is a function in C Language

Q. what is void main()

Q. what is int main()

Q. what is main() function in c Language

Ans :  The Main function : In many programming languages, the main function is where a program starts execution. It is responsible for the high-level organization of the program's functionality, and typically has access to the command arguments given to the program when it was executed.

The main function is generally the first programmer-written function run when a program starts, and is invoked directly from the system-specific initialization contained in crt0 or equivalent. However, some languages can execute user-written functions before main runs, such as the constructors of C++ global objects.

Example :
int main(void)
int main(int argc, char **argv)
int main(int argc, char *argv[])
int main()


Function prototype : A function prototype in C, Perl or C++ is a declaration of a function that omits the function body but does specify the function's return type, name, arity and argument types. While a function definition specifies what a function does, a function prototype can be thought of as specifying its interface.

In a prototype, argument names are optional, however, the type is necessary along with all modifiers (i.e. If it is a pointer or a const argument).




SOME REFERENCE SITES TO UNDERSTAND C, TURBO C

WIKIPEDIA - AN INTRODUCTION TO C PROGRAMMING LANGUAGE




INTRODUCTION TO C PROGRAM, FIRST C PROGRAM, HOW TO START C PROGRAM, BASIC COMMANDS OF C PROGRAM, FUNCTIONS OF C PROGRAM, BASIC SYMBOLS IN C LANGUAGE

#include<stdio.h>   WHAT IS THE MEANING OF # IN C;

What is the Meaning of Hash # in Turbo C, C, Turbo C3, Turbo C2 etc.

example  :       #include<stdio.h>
or Question :  What is  #include<stdio.h> ?


Answer :
#    - it indicates a pre-processor command
     - The first line of the program contains a
       preprocessing directive, indicated by
       #include. This causes the compiler to
       replace that line with the entire text
       of the stdio.h standard header, which
       contains declarations for standard input
       and output functions such as printf.
       The angle brackets surrounding stdio.h
       indicate that stdio.h is located using
       a search strategy that prefers standard
       headers to other headers having the
       same name. (Double quotes are used to
       include local or project-specific
       header files.)

A SIMPLE C PROGRAM HELLO WORLD (YOUR FIRST C PROGRAM)

                    //your first c program


#include<stdio.h>  //to include standard input output header file
#include<conio.h>  //to include console input output header file


void main()        //void main this is called main function 

                   //as there are many functions in c language
{                  //{ indicates starting point of block or function



  clrscr();        //to clear the previous screen in turbo c3


  printf("Hello"); //this is the text to print on screen



  getch();         //prompts the user to press a character and 
                   //that character is not printed on screen, 
                   //getch header file is conio.h.


}                  //{ indicates end point of block or function

INTRODUCTION TO TURBO C

INTRODUCTION TO TURBO C (INTRO AND HISTORY)

C (pronounced see, like the letter C) is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system.

Although C was designed for implementing system software, it is also widely used for developing portable application software.

C is one of the most widely used programming languages of all time and there are very few computer architectures for which a C compiler does not exist. C has greatly influenced many other popular programming languages, most notably C++, which began as an extension to C.

Significant Language Features

C is a powerful, flexible language that provides fast program execution and imposes few constraints on the programmer. It allows low level access to information and commands while still retaining the portability and syntax of a high level language. These qualities make it a useful language for both systems programming and general purpose programs.

C's power and fast program execution come from it's ability to access low level commands, similar to assembly language, but with high level syntax. It's flexibility comes from the many ways the programmer has to accomplish the same tasks. C includes bitwise operators along with powerful pointer manipulation capabilities. C imposes few constraints on the programmer. The main area this shows up is in C's lack of type checking. This can be a powerful advantage to an experienced programmer but a dangerous disadvantage to a novice.

Another strong point of C is it's use of modularity. Sections of code can be stored in libraries for re-use in future programs. This concept of modularity also helps with C's portability and execution speed. The core C language leaves out many features included in the core of other languages. These functions are instead stored in the C Standard Library where they can be called on when needed.. An example of this concept would be C's lack of built in I/O capabilities. I/O functions tend to slow down program execution and also be machine independent when running optimally. For these reasons, they are stored in a library separately from the C language and only included when necessary.

History of C Language :  Ken Thompson and Dennis Ritchie

The initial development of C occurred at AT&T Bell Labs between 1969 and 1973; according to Ritchie, the most creative period occurred in 1972. It was named "C" because its features were derived from an earlier language called "B", which according to Ken Thompson was a stripped-down version of the BCPL programming language.

The origin of C is closely tied to the development of the Unix operating system, originally implemented in assembly language on a PDP-7 by Ritchie and Thompson, incorporating several ideas from colleagues. Eventually they decided to port the operating system to a PDP-11. B's inability to take advantage of some of the PDP-11's features, notably byte addressability, led to the development of an early version of C.

The original PDP-11 version of the Unix system was developed in assembly language. By 1973, with the addition of struct types, the C language had become powerful enough that most of the Unix kernel was rewritten in C. This was one of the first operating system kernels implemented in a language other than assembly. (Earlier instances include the Multics system (written in PL/I), and MCP (Master Control Program) for the Burroughs B5000 written in ALGOL in 1961.)