Skip to main content

Posts

"Action Script" from Programming Template

How do I get memory, i.e how are variables declared ? And specific facts and constraints about variables ? Ex : var food:String; food=”pizza”; Var : keyword, needed by syntax Food: user specific name String: data type, it can be class name or interface name. trace("My favorite food is " + food); // displays "My favorite food is pizza" ________________________________________________________________ How do we get the entry point for the program execution ? Select File > New. In the New Document dialog box, select Flash Document, and click OK. A new Flash window is displayed. Select File > Save. Select the same folder that contains the Greeter.as class file, name the Flash document HelloWorld.fla, and click OK. * In the Flash Tools palette, select the Text tool, and drag across the Stage to define a new text field, approximately 300 pixels wide and 100 pixels high. * In the Properties panel, with the text field still selected on the St...

Story of a Program

H i, I'm a program. I have seen two worlds. People call then "Main Memory" and "Secondary Memory". Secondary Memory is my home, this is where I spend most of the time. It is my Home. Main memory(aka Primary Memory) is my work place, this is the place from where I turn into Action using processor. I enter the Primary Memory aka Main memory. I have to take a toke and wait in the lounge. This is called as ready state. Some times the lounge gets crowded and few programs from here will be sent to another big lounge, it is called "Ready Suspended". So once we get the chance to enter the processor we move from ready state to "Running" state. While we are running inside processor we may need some resources and we get have to wait for those resources to be available. Then we are sent to another state from the "Running" state. This state is similar to "Ready Suspended ", which we went when we were waiting in the lounge...

Programming Language Learning Template

Programming language is a convenience of a programmer to define how the machine should behave. Usually students who are new to computer science domain think that learning a programming language is a hard thing. Also they get bogged down by the vast API and STL created for any particular language. In such situations you need to understand that you don't need to memorize every single function and API calls to say that you know a particular language. Even people who are involved in the language development are not aware of every single function out there. But you should know the core components of any particular programming language. This should be enough to get the things done at any level. For any particular necessity of a programming construct you should be able to be in a position to find it the documentation of such particular programming language. So how do I know that 20% of the language to get to the core of a programming language ? The list of questionnaire presented he...

Using "this" as an Argument of Callback method[javaScript]

function destroyer(arr) {   // Remove all the values   var arg = Array.from(arguments);   var initial=arg[0];   var destr=[];   for(i=1;i<arg.length;i++)     destr[i-1]=arg[i];   for(i=0;i<destr.length;i++)   initial=initial.filter(tester,destr[i]);   return initial; } function tester(value){   if(value==this)     return false;   else   return true; } destroyer([1, 2, 3, 1, 2, 3], 2, 3); //OUTPUT : [1,1] Explanation : .filter() will remove the present element if callback function returns false. 'arguments' is a language defined object which has the arguments passed into the function,but this will not be in array format. Array.from(arguments) returns the arguments in array format. Second argument passed to the .filter() method is visible to callback function (in this case "tester") via "this" object inside the callback function.

Zeros in Factorial Inside out !

Here is the C Program to generate a series which leads us to understand the number of zeros in a Factorial: -------------------------------------------------------------------------------------------------------------------------- #include <stdio.h> #include<stdlib.h> int ZerorsInFactorial(int number); int main(int argc, char **argv) { //printf("hello world\n");     //This is to see the howmany zeros will be there in a factorial , let that be P.     //The values P take as we move towards infinity     int i=0;FILE *fptr;     fptr=fopen("program.txt","w");     if(fptr==NULL){       printf("Error!");       exit(1);     }     while(i<1000)         {             fprintf(fptr,"%d zeros in %d factorial\n",ZerosInFactorial(i),i);     printf("%d zeros in %d factorial\n",ZerosInFactorial(i),i);i++; ...

Python Crash Course : Part 2

For learning core of any programming language it is necessary to learn three fundamental types of language constructs : 1.        Sequential Statements 2.        Control Statements 3.        Iterative Statements It is just that simple , only three things to learn .Cool !! Sequential Statements in Python ·          Variables (memory) are integral part of any algorithm implementation. ·          There is no need of declaring data type of the variable used, Python implies the data type based on context. Which is similar in Scripting language like JavaScript[here we use 'var' keyword]. Example : x=1 , x=’string’ , x=0.000 . Based on type of data at RHS the datatype of variable is implied. ·          INPUT and OUTPUT constructs in Python  : INPUT : ...

Arduino Code To Wire any Serial Device

#include <SoftwareSerial.h> SoftwareSerial mySerial(10, 11); // RX, TX ]] change this to pin to which arduino is connected void setup() {   // Open serial communications and wait for port to open:   Serial.begin(9600);   while (!Serial) {     ; // wait for serial port to connect. Needed for native USB port only   }   // set the data rate for the SoftwareSerial port   mySerial.begin(9600); } void loop() { // run over and over   if (mySerial.available()) {     Serial.write(mySerial.read());   }   if (Serial.available()) {     mySerial.write(Serial.read());   } }