Showing posts with label PROGRAMMING TUTORIALS. Show all posts
Showing posts with label PROGRAMMING TUTORIALS. Show all posts

Tuesday, 27 March 2012

Basic Functions & programs of C | 2nd Session

Hello friends so today as i said today i'm gonna teach you some common function & also write some basic programs of c . so lets start.



The structure of C program
















C is made up entirely of building blocks which have a particular ‘shape’ or form .A program is made up of functions, functions are made up of statements and declarations surrounded by curly braces { } .One and only one of these functions in the program must have the name main(). This function is always the starting point of a C program . The parentheses ‘()’ which follow the name of the function must be included even though they apparently serve no purpose at this stage.


’m

The Headers 

#include header.h
At the top of a program file. For instance:
#include "myheader.h"
Includes a personal header file which is in the current directory Or
#include <stdio.h>
includes a file which lies in a standard directory like ‘/usr/include’.
The #include directive is actually a command to the C preprocessor .



Now i will tell you about printf function .

The printf() function 


  • What is full form of  printf  function?  
    - Print format function

  • What is print format (printf) ?
      - It refers to a control parameter used by a class of functions typically associated with some types of     programming languages. The format string specifies a method for rendering an arbitrary number of varied data type parameter(s) into a string. In simple words we can say It provides an superbly versatile way of printing text.


  • How to print a normal string  ?
     -  printf ("..some string..."); 

  • How to print a Integer ?
     - Here we cant use the same command we used in printing the text, we have to use control sequence  -    %d  . The variable someinteger is printed instead of ‘%d’  . Below you see the command .

        printf ("Integer = %d",someinteger);


Here is a small program with its output showing the example of printf function .


/***********************************************************/
/* any program */
/***********************************************************/
#include <stdio.h>
/***********************************************************/
main () /* program */
{
printf ("Astronomy is %dderful \n",1);
printf ("And interesting %d \n",2);
printf ("The ear%d volves around the sun \n",3);
printf ("And makes a year %d you \n",4);
printf ("The moon affects the sur %d heard \n",5);
printf ("By law of phy%d great \n",6);
printf ("It %d when the the stars so bright \n",7);
printf ("Do nightly scintill%d \n",8);
printf ("If watchful providence be%d \n",9);
printf ("With good intentions fraught \n");
printf ("Should not keep up her watch divine \n");
printf ("We soon should come to %d \n",0);
}


Output - 


Astronomy is 1derful \n"
And interesting 2
The ear3 volves around the sun
And makes a year 4 you
The moon affects the sur 5 heard
By law of phy6d great
It 7 when the the stars so bright
Do nightly scintill8
If watchful providence be9
With good intentions fraught
Should not keep up her watch divine
We soon should come to

Then after you have successfully compiled it  then save it as printf.c  . It has its own extension .c, like .exe, pdf .

Some Questions for practice -
1. Why is #include <stdio.h> used for ?

2. Write a command to print out the message "hackingsec".
3. Write a command to print out the number 97?
4. Write two commands to print out "The 2 hackers" two different ways.





So hope its clear & you can solve this question .
if any doubt then please mention it Via comment



.


Sunday, 25 March 2012

Introduction to C language | 1st session

Today is the first session of the c language so i will tell all the basics of c & other  .
















What is C & its uses ?

  • C is called a higher level compiler language which can be used for general purpose programming like for writing small  programs or to write complex application .
  • The C language has been equipped with features that allow programs to be organized in an easy and logical way.
  • C allows meaningful variable names and meaningful function names to be used in programs without any loss of efficiency and it gives a complete freedom of style .
  • C has a set of very flexible loop structure & clean ways of making decisions & this provide an excellent basis of controlling the flow of program .
  • C allows things which are disallowed in other languages: this is no defect but a very powerful freedom .
  • C tries to make the best of a computer by linking as closely as possible to the local environment .

Now i will tell you some characteristics of C :.


Characteristics of C  :

  • Small size
  • Extensive use of function calls
  • Loose typing -- unlike PASCAL
  • Structured language
  • Low level (BitWise) programming readily available
  • Pointer implementation - extensive use of pointers for memory, array, structures and functions .
  • It has high-level constructs.
  • It can handle low-level activities.
  • It produces efficient programs.
  • It can be compiled on a variety of computers.


Basic C Program structure :

  • Preprocessor Commands
  • Type definitions
  • Function prototypes -- declare function types and variables passed to function.
  • Variables
  • Functions




In the session  i will teach you about common functions, commands & also to write small programs so  be updated ...
& any doubt then i'm always ready to answer ;)


Thursday, 22 March 2012

Introduction To Programming

Hello guys , i'm back & from today i will also be posting programming tutorials . All the programming languages tutorials will also be thought . so firstly before you start learning programming you  should know what is programming ? what are their uses ?  who are programmers ? . so in this session i will clear all your Doubts & tell you what is programming . The programming is very important for each & every hacker, without the knowledge of programming you cant claim yourself an hacker , Without the knowledge of programming
you cant write your own exploits . So my dear readers start learning programming & be a programmer .


















What is Programming ?

  • is the process ofdesigning, writing, testing, debugging, and maintaining the source code of computer programs. This source code is written in one or more programming languages. The purpose of programming is to create a set of instructions that computers use to perform specific operations or to exhibit desired behaviors. The process of writing source code often requires expertise in many different subjects, including knowledge of the application domain, specialized algorithms and formal logic.  In simple words i would say  programming is the action or process of writing computer programs. 



Who are programmers ?
  • A programmer, computer programmer, or coder is a person who writes computer software. The term computer programmer can refer to a specialist in one area of computer programming or to a generalist who writes code for many kinds of software. One who practices or professes a formal approach to programming may also be known as a programmer analyst. A programmer's primary computer language (C,C++, Java, Lisp, Python etc.) is often prefixed to the above titles, and those who work in a web environment often prefix their titles with web. The term programmer can be used to refer to a software developer, software engineer, computer scientist, or software analyst 



What are the different Programming languages ?
  • There are many programming languages, i cant mention them all here so you can find them here   .The basic programming languages which is must for an programmer are c, c++, java, java (advance), Perl , Python .


So hope you have understood all what is programming & programmers . so in the next session i will teach you the basics of c language .