Sunday 22 January 2017

Stupid C Programming Part 4 (Data And Data Types)

Data And Data Typed In Programming Language.

        After writing the first program we are going to the next part of programming. Basically we write a program to work on data or to operate on data. The operation can be an arithmetic operation on some numeric data, or can be some sorting operation on a list of names etc. So basically we are going to perform some operation by our program and we need some data to perform this operation. So every data has a data type, for example numeric data, alphabetic data etc.

There are basically 3 types of data we have in C language.

1. Primitive Data Type/Basic Data Types.
2. Derived Data Type.
3. User Defined Data Type.

        Primitive Data Type/Basic Data Types : Primitive data types are defined in programming language. These data type are the base of other data types. There are 3 predefined data types available in C programming language.

1. int or integer data (Ex. : 1,2,10,100 etc).
2 float or fractional data (Ex : 5.9, 5.6,7.2 etc).
3 char or character data (Ex : a, b, x, X, !, @ , # etc).

        Derived Data Type : Derived data types are are data types that are derived from base type of the language. 

Wednesday 4 May 2016

Stupid C Programming Part 3 (The First C Program)

This is the time to write the first program in C Language.

#include<stdio.h>
void main()
                  {
                      printf("This is my first C Program");
                   }
So here we have a program and the program and the program will print the line " This is my first C Program " on the screen.

Now, lets understand the program line by line:
The first line #include<stdio.h> includes a file called Header file. The header files a libraries, where some methods are written to use in the program. Here we use a method printf(), which prints the line in the console and this method is defined in the header file "stdio.h". We can create our own header file and store it to use.

The next line is void main(){}, it defines the "main" method of the program. Every program must contain one main method at least. This is the entry point of a program. the program execution get started from main method. So at the beginning the execution environment finds out the main method and then it executes the instructions written in the program.

The next is printf("This is my first C Program"); this is a pre defined method in stdio.h header file. This method prints something according to the given input. There are several predefined methods in C libraries and we will use some of them time to time.

Tuesday 3 May 2016

Stupid C Programming Part 2 (Introduction To C Programming Language)

Introduction : 


C is a general-purpose high level language that was originally developed by Dennis Ritchie for the Unix operating system. It was first implemented on the Digital Equipment Corporation PDP-11 computer in 1972.
The Unix operating system and virtually all Unix applications are written in the C language. C has now become a widely used professional language for various reasons.
  • Easy to learn
  • Structured language
  • It produces efficient programs.
  • It can handle low-level activities.
  • It can be compiled on a variety of computers.

Some Lines About C : 

  • C was invented to write an operating system called UNIX.
  • C is a successor of B language which was introduced around 1970
  • The language was formalized in 1988 by the American National Standard Institue (ANSI).
  • By 1973 UNIX OS almost totally written in C.
  • Today C is the most widely used System Programming Language.
  • Most of the state of the art software have been implemented using C

Why C ?

C was initially used for system development work, in particular the programs that make-up the operating system. C was adopted as a system development language because it produces code that runs nearly as fast as code written in assembly language. Some examples of the use of C might be:
  • Operating Systems
  • Language Compilers
  • Assemblers
  • Text Editors
  • Print Spoolers
  • Network Drivers
  • Modern Programs
  • Data Bases
  • Language Interpreters
  • Utilities

C Program File : 

All the C programs are written into text files with extension ".c" for example hello.c. You can use "vi",or Turbo C editor of Dev C++ editor to write your C program into a file.
This tutorial assumes that you know how to edit a text file and how to write programming instructions inside a program file.

The C Compilers :

When you write any program in C language then to run that program you need to compile that program using a C Compiler which converts your program into a language understandable by a computer. This is called machine language (i.e. binary format). So before proceeding, make sure you have C Compiler available at your computer. It comes along with all flavour of Unix and Linux.
If you are working over Unix or Linux then you can type gcc -v or cc -v and check the result. You can ask your system administrator or you can take help from anyone to identify an available C Compiler at your computer.
If you don't have C compiler installed at your computer then you can use below given link to download a GNU C Compiler and use it.

Stupid C Programming Part 1 (Introduction To Program and Programming)

Introduction To Program and Programming : 

Program : A program is combination of one or more instruction written in a particular programming language to perform some mathematical calculation or some logical calculation or any thing we want our computer to perform.

Programming : Writing a program using a particular programming language is called programming.

Programming Language : Programming language is a language to write a program. It provide some keywords, some methods, and has some punctuation rules to write a program.
Such As, C, C++, C#, Java etc.

Each and every programming language has some fixed keywords, and provides some method to to perform some task such as, printing a text to monitor or accept some input from keyboard etc, and also defines some rules to write instructions. For example, how we write instruction, where we use comma(,) or a full stop (.) or where we use a semi-colon(;) etc.

Steps To Write a Program : To write a program and to successfully execute the program we need to follow some steps,

Step 1 :   Write the programming instructions in a file in a programming language.

Step 2 : Compile the program using the compiler of the programming language we are using.

Step 3 : The output after compilation we will get an executable file now we can run this file to perform the task.