This is a tutorial on how to send mails via Gmail SMTP using ruby.

Go to the Tutorial

Tagged with:  

C Program Write a Program to Sum of N Number.

On March 7, 2013, in C, by

C Program Write a Program to Sum of N Number.

#include<stdio.h>

main()

{

int n,j,sum=0;

clrscr();

printf(“enter the value”);

scanf(“%d”,&n);

for(j=1;j<=n;j++)

{

printf(“%d\n”,j);

sum=sum+j;

}

printf(“%d\n “,sum);

getch();

}

Tagged with:  

How C programming works?

On March 5, 2013, in General, by

You might wondered about C programming or C++ or java etc, before you enter in computer course or even after taking admission  still you didn’t came to know about C. Well these all are languages of programming for developing codes to innovate a software. And its easy and also it give revolution and innovative ideas to programmer.

Every student must be keen of coding then he would be called Programmer. Yeah its not simple to become a programmer. Using C is is easy coding. C consist header file, identifiers and prototypes.  C is nothing but coding and coding.

This article is just to inform about C.

 

Learn HTML

On February 23, 2013, in HTML, by

learn HTML

Learning the HTML  is easy, if you just remember the tags and codes. For coding you need text editor, i recommend you to use Notepad++ its easy and simple editor. And also Notepad is simple text editor where while saving your project just put name as .html.

HTML stands for Hypertext Markup Language, and it is the most widely used language to write Web Pages. As its name suggests, HTML is a markup language.
Hypertext refers to the way in which Web pages are linked together. When you click a link in a Web page, you are using hypertext.
Markup Language describes how HTML works. With a markup language, you simply “mark up” a text document with tags that tell a Web browser how to structure it to display.

So here is simple steps to create your first HTML document.

  • Open Notepad or another text editor.
  • At the top of the page type <html>.
  • On the next line, indent five spaces and now add the opening header tag: <head>.
  • On the next line, indent ten spaces and type <title> </title>.
  • Go to the next line, indent five spaces from the margin and insert the closing header tag: </head>.
  • Five spaces in from the margin on the next line, type<body>.
  • Now drop down another line and type the closing tag right below its mate: </body>.
  • Finally, go to the next line and type </html>.
  • In the File menu, choose Save As.
  • In the Save as Type option box, choose All Files.
  • Name the file template.html.
  • Click Save.

For example:

<html>

<head>

<title>This is my first HTML</title>

</head>

<body>

<h1>My world of codes</h1>

<p>Its so easy to learn HTML here</p>

</body>

</html>

Now you have created your HTML page so Copy above code and paste in your Notepad or any editor and save it as your name.html.

Here <html>, <title>,<p> are tags of html. All the tags we will learn chapter wise.

HTML Document:

An HTML document starts and ends with <html> and >/html> tags. These tags tell the browser that the entire document is composed in HTML. Inside these two tags, the document is split into two sections:

  • The <head>…</head> elements or elements, which contain information about the document such as title of the document, author of the document etc. Information inside this tag does not display outside.
  • The <body>…</body> elements, which contain the real content of the document that you see on your screen.

HTML Basic Tags
The basic structure for all HTML documents is simple and should include the following minimum elements or tags:
<html> – The main container for HTML pages
<head> – The container for page header information
<title> – The title of the page

<p>- to text a paragraph line
<body> – The main body of the page

Remember when you type<html> to start your document then don’t forget to break it</html> . ” </> is used to close code.

Tagged with:  

C: What is a Compiler ?

On February 21, 2013, in C, by

What is Compiler ?

Compiler complies the whole program and it also display all the errors those are occurred in the Program But the disadvantage of Compiler is that it converts whole Program a time It doesn’t provide the facility to check a statement at a time.

A compiler is necessary to make your source code (..c, .cpp, or .cc files) into a running program. If you’re just starting out, you’ll need to make sure that you have one before you start programming. There are many compilers available on the internet and sold commercially in stores or online. If you have Mac OS X, Linux, or other *nix variant (such as Unix or FreeBSD), you likely have a compiler such as gcc or g++ installed already.

Tagged with:  

C: What are Library files?

On February 21, 2013, in C, by

This is the  component common to C programs is the header file. Information about the standard library functions. These files all end with the .h extension and are added to the program using the #include pre-processor directive. All C compilers use a pre-processor as their first phase of compilation to manipulate the code of the source file before it is compiled.

 The #include directive tells the pre-processor you want to read another file and include it with your program. The most commonly required header file is stdio.h. The directive to include this file is:

#include <stdio.h>

The filename can be in upper or lower case, but lower case is the norm. The stdio.h header file contains, among other things, information related to the printf() function. Notice that the #include directive does not end with a semi-colon. This is because #include is not a keyword that can define a statement, it is an instruction to the compiler.

Example of the simplest programs is:

#include <stdio.h>
int main(void)
{
	printf("My first program in C.");
	getch();
}

At the fourth line “printf(“This is a short C program.”):”

The printf() function outputs the characters that are contained between the quotes to the screen. printf() is a standard library function which displays the string on the screen.

Input from the keyboard:

scanf() is a standard library function to read a value such as an integer or string from the keyboard.

The function named getch() is a get character function that reads the character in from the keyboard, and puts it directly into the program where it is operated on immediately.

 

Tagged with:  

Features of C Programming Language

On February 21, 2013, in C, by

C Programming is widely used in Computer Technology, We can say that C Programming is inspiration for development of other languages. We can use C Programming for different purposes. Below are some of the Features of C Programming language

  1. Low Level Language
    1. C Programming provides low level features that are generally provided by the Lower level languages. C is Closely Related to Lower level Language such as “Assembly Language“.
    2. It is easier to write assembly language codes in C programming.
  2. Portability
    1. C Programs are portable i.e they can be run on any Compiler with Little or no Modification
    2. Compiler and Preprocessor make it Possible for C Program to run it on Different PC
  3. Powerfull
    1. Provides Wide verity of ‘Data Types
    2. Provides Wide verity of ‘Functions’
    3. Provides useful Control & Loop Control Statements
  4. Bit Manipulation
    1. C Programs can be manipulated using bits. We can perform different operations at bit level. We can manage memory representation at bit level. [Eg. We can use Structure to manage Memory at Bit Level]
    2. It provides wide verity of bit manipulation Operators. We have bit-wise operators to manage Data at bit level.
  5. High Level Language
    1. It is more User friendly as compare to Previous languages. Previous languages such as BCPL,Pascal and other programming languages never provide such great features to manage data.
    2. Previous languages have there prose  and cons but C Programming collected all useful features of previous languages thus C become more effective language.
  6. Modular Programming
    1. Modular programming is a software design technique that increases the extent to which software is composed of separate parts, called modules
    2. C Program Consist of Different Modules that are integrated together to form complete program
  7. Efficient Use of Pointers
    1. Pointers has direct access to memory.
    2. C Supports efficient use of pointer .
    3. Please Like us on Facebook to continue reading.

Basic Elements of C

On February 21, 2013, in C, by

Any programming language has its basic elements and syntax rules with which a baby programmer must be familiar. So, that he/she can understand the programming language. The basic elements of c language are; Characters set, variables, data types, constants, keywords (reserved words in c language), variables declaration, expression, statement, arrays, identifiers.

Special characters:
,  Comma		&  Ampersand
.  Dot			^  Caret
;  Semicolon 		*  Asterisk
:  Colon 		> Greater than sign 
!  Exclamation Mark 	(  Opening Parenthesis 	
|  Pipe Line		)  Closing Parenthesis
/  Slash		-  Minus Sign
?  Question Mark 	+  Plus Sign 
'  Single Quotation 	<  Less than sign
"  Double Quotation 	[  Left Bracket , 
\  Backslash		]  Right Bracket 
~  Tilde		{  Open Brace
_  Underline		}  Close Brace

 
These below elements help to build up a good C program.

  • Tokens
  • Comments
  • Keywords
  • Identifiers
  • Constants
  • Variables

Tokens

 
The smallest individual units of the program are tokens. There are six types of tokens. They are Keywords, identifiers, constants, strings, operators and special symbols.

 

Keywords

 
Keywords have a standard predefined meaning and they should be used only for their intended purpose. The keywords should be written in lower case.

Auto                   double             int                         struct 
Break                 else                     long                     switch 
Case                   enum               register             typedef 
Char                   extern             return               union 
Const                 float                   short                   unsigned 
Continue          for                       signed                 void 
default              goto                   sizeof                 volatile 
Do                       if                         static                 while

 

Identifiers

 
“Identifiers”  are the names you supply for variables, types, functions in your program. Identifier names must differ in spelling and case from any keywords. You cannot use keywords ‘either C or My world of codes’ as identifiers; they are reserved for special use. You create an identifier by specifying it in the declaration of a variable, type, or function. In this example,result is an identifier for an integer variable, and main and printf are identifier names for functions.

Now we must differentiate between Keywords and Identifiers. Keywords are special words reserved by the language and Identifiers are names which you can use to call your items (I use the word ‘items’ because I am assuming you don’t know of C’s building blocks, such as: structs, classes, methods, etc.).

Rules

  •  Identifiers may be alphabets, digits and special characters with underscore.
  •  The first character must be alphabet
  •  No special characters are allowed.

 


Constants

 
The quantity whose value does not change during the program execution is called as constants. There are three types of constants.

  1. Numeric constants
  2. Character constants
  3. String constants

 

  1. Numeric constants
  2. It is made up of digits and some special characters. They are divided into integer and floating point.

    Integer- It is made up of digits without decimal point. The value ranges from -32,708 to +32,627.

    Integer constant          Range

    Long integer                      2,147,483,648 to 2,147,483,647

    Short integer                     -128 to 127

    Unsigned integer             0 to 65,535

    Real constant-A number with one decimal point is called real constant. The real constant can be expressed in one of the two forms

    • Fractional form- a number  with one decimal point eg-0.52
    • Exponent form- It is used to represent very large and very small real constants.
    • Eg-0.251E-5
  3. Character constants
  4. There are two types of character constant

    1. Direct
    2. Escape sequence

    Direct

    A single character is enclosed within single quotation marks. Eg-‘A’

    Escape sequence

    More than one character begins with single quotation mark. The first character must be (/).

    Character for Bell (Alert) ‘a’.  Character for Backspace ‘b’.

    Character for Horizontal Tab ‘t’.  Character for Vertical Tab ‘v’.

    Character for Newline (Line Feed) ‘n’.  Character for Form Feed ‘f’.

    Character for Carriage Return ‘r’.  Character for Quotation Mark ‘”‘.

    Character for Apostrophe ”’.  Character for Question Mark ‘?’.

    Character for Backslash ‘\’.  Character for Null ”.

    Character for Bell (Alert) ‘a’.  Character for Backspace ‘b’.

    Character for Horizontal Tab ‘t’.  Character for Vertical Tab ‘v’.

  5. String constant
  6. A sequence of characters enclosed within double quotes. It can be digits, alphabets, special characters.

    Example : “CHICAGO”  “12345”

 

Variables

 

A symbol or name that stands for a value. For example, in the expression “x+y”

x and y are variables. Variables can represent numeric values, characters,character strings, or memory addresses.

Variables play an important role in computer programming because they enable programmers to write flexible programs. Rather than entering data directly into a program, a programmer can use variables to represent the data. Then, when the program is executed, the variables are replaced with real data. This makes it possible for the same program to process different sets of data.

Every variable has a name, called the variable name, and a data type. A variable’s data type indicates what sort of value the variable represents, such as whether it is an integer, a floating point number, or a character.

The opposite of a variable is a constant. Constants are values that never change. Because of their inflexibility, constants are used less often than variables in programming.

Types of variables:

  • Integer
  • Long integer
  • Short integer
  • Unsigned integer
  • Floating pint
  • Double
  • Character
  • Signed character
  • Unsigned character
  • String.
Tagged with:  

C: Basics of C programming.

On February 21, 2013, in C, by

Introduction to C

A high-level programming language developed by Dennis Ritchie at Bell Labs in the mid 1970′s. Although originally designed as a systems programming language, C has proved to be a powerful and flexible language that can be used for a variety of applications, from business programs to engineering. C is a particularly popular language for personal computer programmers because it is relatively small, it requires less memory than other languages.
The first major program written in C was the UNIX operating system, and for many years C was considered to be inextricably linked with UNIX. Now, however, C is an important language independent of UNIX.
Although it is a high-level language, C is much closer to assembly language than are most other high-level languages. This closeness to the underlying machine language allows C programmers to write very efficient code. The low-level nature of C, however, can make the language difficult to use for some types of applications.

Basic of C programming

Why we use C programming language?

C is one of the most popular programming languages of all time and there are very few computer architectures for which as C compiler does not exist. C has greatly influenced many other popular programming languages, most is C++, which began as an extension to c. C is an imperative systems implementation language. It was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support. C was therefore useful for many applications that had formerly been coded in assembly language.

Characteristics:-

Like most imperative languages in the ALGOL tradition, C has facilities for structured programming and allows lexical variable scope and recursion, while a static type system prevents many unintended operations. In C, all executable code is contained within functions. Function parameters are always passed by value. Pass-by-reference is simulated in C by explicitly passing pointer values.

Heterogeneous aggregate data types (struct) allow related data elements to be combined and manipulated as a unit. C program source text is free-format, using the semicolon as a statement terminator.

C also exhibits the following more specific characteristics:

Variables may be hidden in nested blocks Partially weak typing. for instance, characters can be used as integers. Low-level access to computer memory by converting machine addresses to typed pointers Function and data pointers supporting ad hoc run-time polymorphism array indexing as a secondary notion, defined in terms of pointer arithmetic.

A pre-processor for macro definition, source code file inclusion, and conditional compilation Complex functionality such as I/O, string manipulation, and mathematical functions consistently delegated to library routines A relatively small set of reserved keywords A large number of compound operators, such as +=, -=, *=, ++ etc.

Tagged with:  

Java: How to take a screenshot

On September 25, 2012, in JAVA, by

We can easily take a screenshot using java. Use Use Robot#createScreenCapture().
createScreenCapture() creates an image containing pixels read from the screen. This image does not include the mouse cursor.

Use the code given below to take a screenshot and save the image as a png file.

BufferedImage screenimage = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
ImageIO.write(screenimage, "png", new File("/screenshot.png"));

Hope, it helps! :)

Tagged with:  


Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

  • CG Lab Programs in C
  • Dipin Krishna
  • Linux Tips

Archives

All entries, chronologically...

Premium WordPress Themes