Introduction To Programming

Why programs ? Programming is nothing but making the computers think the same way a human thinks. Programs are made for obtaining a specific solution which can even be solved by humans which when solved by us may consume time..

Wednesday, February 3, 2010

NUMBER[ARRAY] -part 2

CODING:

#include< stdio.h >
main()
{
printf("%c",2["INISROH"]);
}

OUTPUT


I



Refer the previous post to know logic of this program.

Number[character array]

Today i'm going to give you a interesting logical programs.

CODING:

#include< stdio.h >
int main()
{
char a[]="INISROH";
printf("%c",4[a]);
return 0;
}

OUTPUT


R


How?


a[i]=*(a+i) (we can represent a[i] using the ptr like this)
*(a+i)=*(i+a)
*(i+a)=i[a]
here 'i' is 0,1,2,...n
n is length of string