Sunday, June 16, 2013

Programming in C - 2. Input/Output Operations

C language does not have any built-in Input- Output (I/O) statements as a part of its syntax.
All the Input/Output operations are carried out through functions calls such as printf() and scanf()


scanf() 



  • General purpose console input function. Also used to input a data line containing mixed mode data.
  • syntax : scanf ("format specifier", variable_list); // end with semi-colon and case-sensitive.
  • 'format specifier' specifies the field format in which the data has to be entered.
  • 'variable list' specifies the address of the location where the data is stored.
  • use '%' before format sepecifier and '&' before a variable name
Format Specifier
  • It contains specifications for the interpretation of input data.
  • '%' conversion character.
  • list of format specifier
    • %c To read a single character
    • %d To read a decimal integer
    • %e To read a floating point value
    • %f  To read a floating point number
    • %g To read a floating point value
    • %o to read an octal value
    • %x To read an Hexadecimal value
    • %s To read a String
    • %u To read an unsigned integer
  • For reading a string 
    • scanf("%s", &st); // st contains the string value
  • For reading two values
    • scanf("%d,%d",&a,&b);\
  • Features :
    • format specification and variable list must correctly match the same order
    • The format specifier must be separated by space or comma and vairable list by comma
    • use of invalid match between format specifier and variable list will make the scanf() to terminate the reading of data

printf()

  • syntax : printf ( " format specifier ", variable list);
  • never takes the print to the new line so we use '\n' for a new line
  • eg : printf(" no of chocolates = %d \n no of sweets = %d",&a,&b); // ouput : no of chocolates = 12 [next line ] no of sweets = 13 // where a = 12 and b =13
  • list of escape sequences like \n 
    • \b     back space
    • \f      Form feed
    • \n     New line
    • \r     Carriage return
    • \t     Horizontal tab
    • \"     Double quote mark
    • \'     single quote mark
    • \0    null
    • \\     Back slash
    • \v    Vertical tab
    • \a    Alert ( rings a bell)
    • \o    Octal constant
    • \x     Hexadecimal constant

Sample Program :


First you need :
Compiler :
online compiler : codepad.org
offline compiler : http://edn.embarcadero.com/article/20633 (borlan c++ compiler)
                           http://www.digitalmars.com/ (digital mars c compiler)

01 #include <stdio.h> // imports the header file stdio.h which contains the definitions of scanf() and printf()
                                     functions.
02 void main() // execution of the program begins in the main() function
03 {
04       printf(" Hello world ");
05 } // main() ends here

output : Hello world 



Next Article : Programming in C - 3. Control Statements and Arrays

Saturday, June 15, 2013

Programming in C - 1. Fundamentals

C  is a general-purpose programming language initially developed by Dennis Ritchie between 1969 and 1973 at AT&T Bell Labs. ( Source : Wiki )
Middle Level Language
Portable
Structured language.

The C grammer :

  1. Charecter set : used to form words, numbers and expressions , in any programming language. It includes Letters, Digits, Special charecters
  2. Token : Fundamental units of C language. It include  Identifiers, Keywords, Literals, Operators, white Spaces.
    • Identifiers : Name of variable , a constant or a function.
    • keywords : C has almost 32 keywords. They are reserved words which cannot be used for naming variables.
    • Constants : It is the Value of Quantitiy.
  3. Data Types : It is used to determing the kind of data the variable can store. It has four basic data types int, float, char and void.
    • Integer : these are numbers without decimal part that may or may not be prefixed with a negative sign.
    • Float : These are numbers with decimal part in it.
    • Void : It has no value. It can be used to declare a funtion that retuns no values, it creates generic pointers.
  4. Operators : An Operator is a symbol that tells the compiler to perform specific mathematical or logical manipulation.
    • assignment : =, ==
    • auto increment / decrement : ++, --
    • ternary : (x>y)?x:y
    • logical : && (AND), || (OR), ! (NOT)
    • relational : <, >, <=,>=
    • cast : (type_name) expression
    • arithmetic : +, -, %
    • bitwise : &, |, -(compliment)
    • special

Next : Programming in C - 2. Input and output Operations

Saturday, June 8, 2013

Minor Java Project - Police Station Complaint Management with Documentation and Source code


Police Station Complaint Management


Java Project for minor project submission ... 

INTRODUCTION

Police Station Complaint Management System is software which is helpful for Citizens, Business Owner, Public Service Units as well as the Police Authority in the current system all the activities are done manually. It is very time consuming and costly. Our Police Station Complaint Management System deals with the various activities related to the common citizens.
In this Software the Citizens, Business Owners, Public Service Units are needed to register first to insert complaint or view police stations details. They are then required to login in order to Lodge and FIR (First Information Report). Citizens, Business Owners, Public Service Units have another facility which is viewing Police Station Details. This will help them know Emergency Numbers and Police Station Details and Officer in Charge.
This Software is also decreases the work load of Police Management. They have the facility to View Lodged Complaints, Delete Lodged Complaints, View Police Station Details, and Update Police Station Details.

Finally this Software is to decrease the work load of both Public and Police.


File Enclose :
Documentation
Access Database file
Source Code ( for Netbeans IDE)

Clik the link to download full zip
link :http://www.mediafire.com/?1yggg2eb1bnbp3b