Ads 468x60px

Labels

Monday, 17 September 2012

Reverse of a string using pointers

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
char *a;
clrscr();
printf("enter a string");
scanf("%s",a);
i=0;
while(*(a+i)!='\0')
i++;
for(j=i-1;j>=0;j--)
printf("%c",*(a+j));
getch();
}

C Program for Factorial of a Number using Recursive Functiol

#include<stdio.h>
#include<conio.h>
long int factorial(int n);
void main()
{
int n;
clrscr();
printf("Enter the number:\n\n");
scanf("%d",&n);
printf("Factorial of %d is %ld",n,factorial(n));
getch();
}
long int factorial(int n)
{
if(n<=1)
{
return(1);
}
else
{
n=n*factorial(n-1);
return(n);
}
}

Thursday, 13 September 2012

Switch Case control structure


SWITCH stmt is used for handling n number of decisions at a time.
 Hence it is also known as multi way decision making stmt.
SWITCH STATEMENT can't be applied to float and double.
 Break stmt transfers the control out of the switch stmt.
Syntax

switch(choice)
  {
  case 1:block of stmt:-1;
  break;
  case 2:block of stmt:-2;
  break;
  …………………….
  ……………………..
  ………………………
  case n:    block of stmt:-n;
  break;
  default: invalid stmt;
  break;
  }


sample program 

Logical operators workshop


Logical && and logical || 
logical && : If all are true then only true otherwise false.
logical || : if any one is true then it is true otherwise false.
Program on logical operators 
 A company insures its drivers in the following cases:
− If the driver is married.
− If the driver is unmarried, male & above 30 years of age.
− If the driver is unmarried, female & above 25 years of age.
In all other cases the driver is not insured. If the marital status, sex and age of the driver are

Else-if Control Structure


Else-if:
      A Multipath decision is a chain of ifs in which the statement associated with each else is an if.
Syntax:
  if(condition-1)
  stmt-1;
     else if(condition-2)
         stmt-2;
  else if(condition-3)
     stmt-3;
      ………………….
      else if(condition-n)
        stmt-n;
  else
  defalut stmt;
stmt-x;

Sample Program :

If else control structure


C  uses the keyword if-else to implement the decision control instruction.
Syntax
if(test condition-1)
{
             if(test condition-2)
  {
                block of stmt-1;
  }
  else
  {
                  block of stmt-2;
               }
}
  else
  {
     block of stmt-3;
  }
Stmt-x;

Note: braces are mandatory when, corresponding to if or else statement, multiple steps are to be executed.
Sample program 

If Control Structure


if   
C  uses the keyword if to implement the decision control instruction.
if statement can’t terminate with semicolon, but by mistake if we terminate ,compiler won’t give any error.
Syntax
if (test condition)
{
------------------------------------
------------------------------------
-------------------------------------               block of statements
--------------------------------------
}
Stmt-x;

Sample if program

Schaum's Outline of Programming with C



Head First Programming

Looking for a reliable way to learn how to program on your own, without being overwhelmed by confusing concepts? Head First Programming introduces the core concepts of writing computer programs - variables, decisions, loops, functions, and objects - which apply regardless of the programming language. This book offers concrete examples and exercises in the dynamic and versatile Python language to demonstrate and reinforce these concepts.

Learn the basic tools to start writing the programs that interest you, and get a better understanding of what software can (and cannot) do. When you're finished, you'll have the necessary foundation to learn any programming language or tackle any software project you choose.


Head First SQL

Maybe you've written some simple SQL queries to interact with databases. But now you want more, you want to really dig into those databases and work with your data. Head First SQL will show you the fundamentals of SQL and how to really take advantage of it.


Head First JavaScript

Want to make the leap from writing HTML and CSS web pages and create dynamic web applications? Want to take your web skills to the next level? It sounds like you're ready to learn the Web's hottest programming language: JavaScript. Head First JavaScript is your ticket to going beyond copying and pasting the code from someone else's web site, and writing your own interactive web pages.



Head First HTML5 Programming

HTML has been on a wild ride. Sure, HTML started as a mere markup language, but more recently HTML's put on some major muscle. Now we've got a language tuned for building web applications with Web storage, 2D drawing, offline support, sockets and threads, and more. And to speak this language you've got to go beyond HTML5 markup and into the world of the DOM, events, and JAVASCRIPTS APIs.


                                       CLICK HERE TO DOWNLOAD

Head First HTML with CSS & XHTML

Tired of reading HTML books that only make sense after you're an expert? Then it's about time you picked up Head First HTML with CSS & XHTML and really learn HTML. You want to learn HTML so you can finally create those web pages you've always wanted, so you can communicate more effectively with friends, family, fans, and fanatic customers. You also want to do it right so you can actually maintain and expand your web pages over time, and so your web pages work in all the browsers and mobile devices out there. So what are you waiting for? Leave those other dusty books behind and come join us in Webville. Your tour is about to begin.

                                                       Click Here To Download

Head First C#

You want to learn C# programming, but you're not sure you want to suffer through another tedious technical book. You're in luck: Head First C# introduces this language in a fun, visual way. You'll quickly learn everything from creating your first program to learning sophisticated coding skills with C# 4.0, Visual Studio 2010 and .NET 4, while avoiding common errors that frustrate many students.
                                     Click Here To Download

Head First Java

                                                   Click Here To Download
     Head First Java delivers a highly interactive, multisensory learning experience that lets new programmers pick up the fundamentals of the Java language quickly. Through mind-stretching exercises, memorable analogies, humorous pictures, and casual language, Head First Java encourages readers to think like a Java programmer. This revised second edition focuses on Java 5.0, the latest version of the Java development platform.

Head First C

                Head First C provides a complete learning experience for C and structured imperative programming. With a unique method that goes beyond syntax and how-to manuals, this guide not only teaches you the language, it helps you understand how to be a great programmer. You'll learn key areas such as language basics, pointers and pointer arithmetic, and dynamic memory management.
                                     Click Here To Download

Wednesday, 12 September 2012

Simplified pattern code

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,a=4;
clrscr();
for(i=0;i<5;i++)
{
for(j=0;j<9;j++)
{
if((j>7-i||j<i+1)
printf("%d ",a);
else
printf("  ");
}
printf("\n");
a--;
}
getch();
}

Tuesday, 11 September 2012

C Pattern code

#include<stdio.h>
#include<conio.h>
void main()
{
 int i,j,k;
 clrscr();

C code for swapping of two numbers without using 3rd varible,+,-,*,/


#include<stdio.h>
#include<conio.h>
void main()
{
int x,y;
clrscr();
printf("\n enter the elements\n");
scanf("%d%d",&x,&y);
printf("\n before swaping x=%d,y=%d",x,y);
x=x^y;
y=y^x;
x=x^y;
printf("\n after swaping x=%d y=%d",x,y);
getch();
}

List of escape sequence in C:

An escape sequence is a character used in C which is not printed in Screen while printing it.It is a character combination consisting of a backslash (\) which is followed by a letter or a combination of digits.
Escape sequence is a single character and thus can be stored in a character constant.

List of escape sequence in C:
The following list contains a list of  escape sequence in ANSI C and their use:
\a is used to give an audible alert or beep sound.
\0 is used to print a null character.
\b is used to delete one character to the left of cursor , equivalent to backspace.
\f is used for form feed , or to feed a blank page when printing documents.
\t is used for horizontal tab , or to move the cursor to nest tab stop position.
\n is used for line feed , or to feed a blank line while printing documents.
\v is used for vertical tab , or to assign more space from the previous line.
\r is used for carriage return , or to move the cursor to the nest line during typing.
\\ is used to print a backslash.
\’ Is used to print a single quote.
\” is used to print a double quote.

Thursday, 6 September 2012

Understanding C program execution

Animation of program execution
This animation shows the execution of a simple C program. By the end of this article you will understand how it works!
The C programming language is a popular and widely used programming language for creating computer programs. Programmers around the world embrace C because it gives maximum control and efficiency to the programmer.
If you are a programmer, or if you are interested in becoming a programmer, there are a couple of benefits you gain from learning C:
  • You will be able to read and write code for a large number of platforms -- everything from microcontrollers to the most advanced scientific systems can be written in C, and many modern operating systems are written in C.

The-C-programming-language-Ritchie-Kernighan

Dennis Ritchie



Object Oriented Programming With C++ By Balagurusamy

 E. Balagurusamy


Program using printf() and scanf()


printf(): It displays output on the screen.
scanf(): It accepts input from user.

#include <stdio.h>
int main()

Precedence & Associativity of operators


Operators in C


There are three types of operators. A unary expression consists of either a unary operator prepended to an operand, or the sizeof keyword followed by an expression. The expression can be either the name of a variable or a cast expression. If the expression is a cast expression, it must be enclosed in parentheses. A binary expression consists of two operands joined by a binary operator. A ternary expression consists of three operands joined by the conditional-expression operator.

C includes the following unary operators:

Input and Output functions in C


printf

This offers more structured output than the putchar. Its arguments are, in order; a control string, which controls what get printed, followed by a list of values to be substituted for entries in the control string.

The prototype for the printf() is:

First C Program


Open command prompt
C:\TC\BIN > TC.EXE
Select New from the File menu.
Type the program in the editor.

Rules that are applicable to all C programs



                                                                                                                
   (a)  Each instruction in a C program is written as a separate statement. Therefore a complete C program
 would comprise of a series of statements.
     (b)  The statements in a program must appear in the same order in which we wish them to be
            executed; unless of course the logic of the problem demands a deliberate ‘jump’ or transfer of
            control to a statement, which is out of sequence.
     (c)  Blank spaces may be inserted between two words to improve the readability of the statement. 
           However, no blank spaces are allowed within a variable, constant or keyword
     (d)  All statements are entered in small case letters.
     (e)  C has no specific rules for the position at which a statement is to be written. That’s why it is 
          often called a free-form language.
     (f)  Every C statement must end with a ;. Thus ; acts as a statement terminator. 

Keywords,Variables and Constants in C

"Keywords" are words that have special meaning to the C compiler.Keywords are also called Reserved words.
Following are the keywords of C language

                                                          32 keyword's in C language

Variables

Variable is a meaningful name of data storage location in computer memory. When using a variable you refer to memory address of computer.

Data Types in C


  1. C has a concept of 'data types' which are used to define a variable before its use.
    C language provides various data types for holding different kinds of values.


                                                              Data Types in C



                                   















                                   Range of different datatypes in C 

Why Flow Chart ?

A flow chart is a graphical or symbolic representation of a process. 

What is C


Why ?
To develop device drivers at lower level,
Most popular in Virtual reality Systems, Embedded Systems,
Widely used in UNIX operating system development.
Who ?
It was designed and written by a man named Dennis Ritchie 
Where and When?

Wednesday, 5 September 2012

C Program to Disable and Enable Usb Port

 

Logic of the program
The logic of the program is simple. The 'C' source file block_usb.c writes the DWORD value of 4 (100 in binary) in the registry settings at "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR\Start" to 'lock' the USB ports.

Programming: Important Tips to Learn It Faster

As the popular idiomatic saying goes, “Rome wasn’t built in a day.” This particular saying applies to programming, which is neither something that cannot be done within a short period of time nor something that may take a long time to accomplish. Programming can be difficult, especially with all the codes, operators, and the dreaded language that one must consider and be reminded of. However, there are a lot of important tips that come with programming, especially for the so-called “neophytes” of the field.  For them, taking programming one step at a time would be very essential. They may take the programming course seriously, but they should not guarantee themselves that they know everything about it. Many others learn too fast that they get lost in the moment. Sticking to the basics would make a difference.

C program to Input and Show a Password


Tuesday, 4 September 2012

How To Execute C Source Code

We Know how to execute C program in C Editor

Now We see how to execute the programs find on Internet

C Code to Find Armstrong Numbers

An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371.