Electronics Passionates

This blog is for all guys who are Passionate in Electronics.

Electronification

The world has electronified in each and every aspect .

Programming Languages

are just too many.Difficult to chhose the one!

Whereever I see

I see 1s and 0s!!

The world of Semiconductors!

The world of semiconductors has become so broad.

Friday, January 20, 2017

Top 10 Most Common Mistakes That Java Developers Make: A Java Beginner’s Tutorial

One of the good resources to get started with Java..................
Please visit once the link given below:
http://www.toptal.com/java/top-10-most-common-java-development-mistakes

Sunday, January 11, 2015

Simple Calculator Project in JAVA

Simple Calculator in JAVA

This is a simple java calculator project to calculate basic arithmetic operations using GUI features of Java extending JFrame Class. The source code is organized in two files. They are:
1. Main.java and
2. Calc_Frame.java

Before actually digging deeper into the source code, lets first see the the output of the project tested with an input expression 9/2*3 whose obvious output after calculation is 13.5
Here are the snapshots:
Figure: Input of test expression 9/2*3


Figure: Result of test input expression.

1. Main.java

//Contents of the file "Main.java"
/**
 * Created by Bikal Adhikari on 12/18/2014.
 */
public class Main {
    public static void main(String[] args) {
        Calc_Frame m=new Calc_Frame("BKL-Calculator");
    }
}

2. Calc_Frame.java

//Contents of the file  "Calc_Frame.java"
/**
 * Created by Bikal Adhikari on 12/18/2014.
 */
import java.awt.Container;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;


public class Calc_Frame extends JFrame {
    JPanel p1 = new JPanel();
    JPanel p2 = new JPanel();
    /*Text Field For emulating Calculator Screen*/
    JTextArea CalcScreen = new JTextArea();
    /*Defining Buttons For keys of Calculator*/
    JButton b0 = new JButton("7");
    JButton b1 = new JButton("8");
    JButton b2 = new JButton("9");
    JButton b3 = new JButton("/");
    JButton b4 = new JButton("4");
    JButton b5 = new JButton("5");
    JButton b6 = new JButton("6");
    JButton b7 = new JButton("*");
    JButton b8 = new JButton("1");
    JButton b9 = new JButton("2");
    JButton b10 = new JButton("3");
    JButton b11 = new JButton("-");
    JButton b12 = new JButton("0");
    JButton b13 = new JButton(".");
    JButton b14 = new JButton("=");
    JButton b15 = new JButton("+");


    public Calc_Frame(String str) {
        super(str);
        Container c = getContentPane();
        p1.setLayout(new GridLayout(1, 1, 10, 450));
        p2.setLayout(new GridLayout(4, 4));
        p1.add(CalcScreen);
        CalcScreen.setEditable(false);



        /*Adding Buttons to panel p2*/
        p2.add(b0);
        p2.add(b1);
        p2.add(b2);
        p2.add(b3);
        p2.add(b4);
        p2.add(b5);
        p2.add(b6);
        p2.add(b7);
        p2.add(b8);
        p2.add(b9);
        p2.add(b8);
        p2.add(b9);
        p2.add(b10);
        p2.add(b11);
        p2.add(b12);
        p2.add(b13);
        p2.add(b14);
        p2.add(b15);
        /*Adding panels to container */
        c.add(p1);
        c.add(p2, BorderLayout.SOUTH);
       /*Setting Size of the Frame*/
        setSize(250, 200);
        setVisible(true);
       /*Handler for Button Event Handling*/
        Handler h = new Handler();
       /*Registering Handler into Action Listener*/
        b0.addActionListener(h);
        b1.addActionListener(h);
        b2.addActionListener(h);
        b3.addActionListener(h);
        b4.addActionListener(h);
        b5.addActionListener(h);
        b6.addActionListener(h);
        b7.addActionListener(h);
        b8.addActionListener(h);
        b9.addActionListener(h);
        b10.addActionListener(h);
        b11.addActionListener(h);
        b12.addActionListener(h);
        b13.addActionListener(h);
        b14.addActionListener(h);
        b15.addActionListener(h);
    }
/*Class to handle event generated by the button press*/
 class Handler implements ActionListener {
     int pos=0;
     public void actionPerformed(ActionEvent e) {
            if (e.getSource() == b0) {
                pos = CalcScreen.getCaretPosition(); //get the cursor position
                CalcScreen.insert("7",pos);
            }
         if (e.getSource() == b1) {
             pos = CalcScreen.getCaretPosition(); //get the cursor position
             CalcScreen.insert("8",pos);
         }
         if (e.getSource() == b2) {
             pos = CalcScreen.getCaretPosition(); //get the cursor position
             CalcScreen.insert("9",pos);
         }
         if (e.getSource() == b3) {
             pos = CalcScreen.getCaretPosition(); //get the cursor position
             CalcScreen.insert("/",pos);
         }
         if (e.getSource() == b4) {
             pos = CalcScreen.getCaretPosition(); //get the cursor position
             CalcScreen.insert("4",pos);

         }
         if (e.getSource() == b5) {
             pos = CalcScreen.getCaretPosition(); //get the cursor position
             CalcScreen.insert("5",pos);
         }
         if (e.getSource() == b6) {
             pos = CalcScreen.getCaretPosition(); //get the cursor position
             CalcScreen.insert("6",pos);
         }
         if (e.getSource() == b7) {
             pos = CalcScreen.getCaretPosition(); //get the cursor position
             CalcScreen.insert("*",pos);
         }
         if (e.getSource() == b8) {
             pos = CalcScreen.getCaretPosition(); //get the cursor position
             CalcScreen.insert("1",pos);
         }
         if (e.getSource() == b9) {
             pos = CalcScreen.getCaretPosition(); //get the cursor position
             CalcScreen.insert("2",pos);
         }
         if (e.getSource() == b10) {
             pos = CalcScreen.getCaretPosition(); //get the cursor position
             CalcScreen.insert("3",pos);
         }
         if (e.getSource() == b11) {
             pos = CalcScreen.getCaretPosition(); //get the cursor position
             CalcScreen.insert("-",pos);
         }
         if (e.getSource() == b12) {
             pos = CalcScreen.getCaretPosition(); //get the cursor position
             CalcScreen.insert("0",pos);
         }
         if (e.getSource() == b13) {
             pos = CalcScreen.getCaretPosition(); //get the cursor position
             CalcScreen.insert(".",pos);
         }

         //Equals to Button
         if (e.getSource() == b14) {
             String str=CalcScreen.getText();
             double a=eval(str);
             CalcScreen.setText(null);
             String abc = Double.toString(a);
             CalcScreen.insert(abc,0);

         }
         if (e.getSource() == b15) {
             pos = CalcScreen.getCaretPosition(); //get the cursor position
             CalcScreen.insert("+",pos);
         }
        }


    }//Class Handler Ends Here

 /**
  * This Function performs job of parsing arithmetic expressions given to the calculator
  * It basically supports parsing expression containing Division, Multiplication, Addition and Subtraction
  * */
    public static double eval(final String str) {
        class Parser {//Nested Class
            int pos = -1, c;

            void eatChar() {
                c = (++pos < str.length()) ? str.charAt(pos) : -1;
            }

            void eatSpace() {
                while (Character.isWhitespace(c)) eatChar();
            }

            double parse() {
                eatChar();
                double v = parseExpression();
                if (c != -1) throw new RuntimeException("Unexpected: " + (char)c);
                return v;
            }

            // Grammar:
            // expression = term | expression `+` term | expression `-` term
            // term = factor | term `*` factor | term `/` factor | term brackets
            // factor = brackets | number | factor `^` factor
            // brackets = `(` expression `)`

            double parseExpression() {
                double v = parseTerm();
                for (;;) {
                    eatSpace();
                    if (c == '+') { // addition
                        eatChar();
                        v += parseTerm();
                    } else if (c == '-') { // subtraction
                        eatChar();
                        v -= parseTerm();
                    } else {
                        return v;
                    }
                }
            }

            double parseTerm() {
                double v = parseFactor();
                for (;;) {
                    eatSpace();
                    if (c == '/') { // division
                        eatChar();
                        v /= parseFactor();
                    } else if (c == '*' || c == '(') { // multiplication
                        if (c == '*') eatChar();
                        v *= parseFactor();
                    } else {
                        return v;
                    }
                }
            }

            double parseFactor() {
                double v;
                boolean negate = false;
                eatSpace();
                if (c == '(') { // brackets
                    eatChar();
                    v = parseExpression();
                    if (c == ')') eatChar();
                } else { // numbers
                    if (c == '+' || c == '-') { // unary plus & minus
                        negate = c == '-';
                        eatChar();
                        eatSpace();
                    }
                    StringBuilder sb = new StringBuilder();
                    while ((c >= '0' && c <= '9') || c == '.') {
                        sb.append((char)c);
                        eatChar();
                    }
                    if (sb.length() == 0) throw new RuntimeException("Unexpected: " + (char)c);
                    v = Double.parseDouble(sb.toString());
                }
                eatSpace();
                if (c == '^') { // exponentiation
                    eatChar();
                    v = Math.pow(v, parseFactor());
                }
                if (negate) v = -v; // exponentiation has higher priority than unary minus: -3^2=-9
                return v;
            }
        }
        return new Parser().parse();
    }
}//Class Calc_Frame ends here


All the necessary project files are included in this zipped archive. To download click here.

"Enjoy Learning"



Friday, May 30, 2014

Arduino based Automatic Air Conditioning System

Hi everyone,today I am gonna share a project entitled  Arduino Based Automatic Air Conditioning System.This is the Arduino version of the project "Temperature Controlled Automatic Air Conditioning System" which was done for Minor Project in which I was a part of the team.As the name implies the main purpose of this project is to devise a system whose sole purpose is to condition or maintain the temperature within the predefined limits.Thus,this system proves to be useful to be used as a Air Conditioning System inside room,offices,departmental stores etc.Apart from that,it can also be used in various industrial applications such as to control the temperature in boilers,refrigerator,AC computers and Laboratories etc.
Now lets look at each element of the design turn by turn:
First lets have a glance at flowchart of the system:
Block Diagram:

Above figure  shows the block diagram of the system that we have designed.Basically, it consists of microcontroller  as a central processor of the entire control operation. The temperature sensor gives the analog output voltage based on the temperature of the room.This analog voltage is fed to the A/D converter.The A/D converter then converts the analog input voltage from the temperature sensor into equivalent binary bits.The converted binary data from the A/D converter is applied to microcontroller.The microcontroller reads binary data from A/D converter,convert it to suitable form and performs different operations based on the value of temperature read from A/D converter.
The LCD is used to display the data given by microcontroller.Microcontroller can turn on dc fan through the optocoupler if required.We have used led as prototype model for heater.If appropriate condition is met microcontroller can turn on heater(i.e. LED).
In this system,if the temperature read is in between 20-25 degree celcius,it is considered normal state.In this condition both fan and heater are off but the temperature and status is displayed in LCD.If the temperature of the room is  greater that 25 degree celcius it is considered to be a situation to turn on fan and turn off heater. If the temperature of the room is in between 25-30 degree celcius it is considered as a situation to turn on fan with speed of level one.In this level,appropriate temperature and status is displayed on the LCD. If the temperature of the room is in between 30-35 degree celcius it is considered as a situation to turn on fan with speed of level two.In this level,appropriate temperature and status is displayed on the LCD. If the temperature of the room is greater than 35 degree celcius it is considered as a situation to turn on fan with speed of level three.In this level,appropriate temperature and status is displayed on the LCD. If the temperature of the room is  less that 20 degree celcius it is considered to be a situation to turn on Heater and turn off fan. If the temperature of the room is in between 10-20 it is considered as a situation to turn one heater on with heat of level one.In this level,appropriate temperature and status is displayed on the LCD. If the temperature of the room is in between 0-10 it is considered as a situation to turn two heater  on with heat of level two.In this level,appropriate temperature and status is displayed on the LCD.

Circuit Diagram:




Source Code:
/**********************************************************
Programmer: Bikal Adhikari                                                              *
Designation: Student                                                                        *
Compiled on: Arduino IDE under Windows 8 OS                                *
Project: Arduino Based Automatic Air Conditioning System                  *
***********************************************************/


#include <LiquidCrystal.h>

 int tempr=0;
 int mtrPin=8;
 int htrPin1=9;
 int htrPin2=10;
 int analogpin=3;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  pinMode(mtrPin,OUTPUT);
  pinMode(htrPin1,OUTPUT);
  pinMode(htrPin2,OUTPUT);
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  analogReference(EXTERNAL);
}



void loop() {
 tempr=readTempr();


 while(tempr<=20 && tempr>10) //Heater level 1 logic
  {
    templateHtr(1);
    lcd.setCursor(6,0);
    lcd.print(tempr);
    digitalWrite(mtrPin,HIGH);
    digitalWrite(htrPin1,HIGH);
    digitalWrite(htrPin2,LOW);
    
    tempr=readTempr();
     }
  while(tempr>=0 && tempr<=10) //Heater level 2 logic
  {
    templateHtr(2);
    lcd.setCursor(7,0);
    lcd.print(tempr);
    digitalWrite(mtrPin,HIGH);
    digitalWrite(htrPin1,HIGH);
    digitalWrite(htrPin2,HIGH);
    tempr=readTempr();
   }
   while(tempr>20 && tempr<=25)  //Normal state logic
    {
    digitalWrite(mtrPin,HIGH);
    templateNorm();
    lcd.setCursor(6,0);
    lcd.print(tempr);
    tempr=readTempr();
     }
  
   while(tempr>25 && tempr<=30)//fan level one logic
    {
    turnhtrOff();
    templateFan(1);
    lcd.setCursor(6,0);
    lcd.print(tempr);
    digitalWrite(mtrPin,LOW);
    delay(25);
    digitalWrite(mtrPin,HIGH);
    delay(75);
    tempr=readTempr();
    }

  while(tempr>30 && tempr<=35) //fan level two logic
  {
    turnhtrOff();
    templateFan(2);
    lcd.setCursor(6,0);
    lcd.print(tempr);
    digitalWrite(mtrPin,LOW);
    delay(50);
    digitalWrite(mtrPin,HIGH);
    delay(50);
    tempr=readTempr();
   }

   while(tempr>35)   //fan level 3 logic
  {
    turnhtrOff();
    templateFan(3);
    lcd.setCursor(6,0);
    lcd.print(tempr);
    digitalWrite(mtrPin,LOW);
    tempr=readTempr();
   }
}//loop closed


int readTempr() //reads temperature 
{
  
 tempr=analogRead(analogpin);
 tempr=tempr*0.48828125;
 return tempr;

}

void templateFan(int a)
{
  lcd.setCursor(0,0);
  lcd.print("TEMPR:");
  delay(50);
  lcd.setCursor(8,0);
  lcd.print("C");
  delay(50);
  lcd.setCursor(10,0);
  lcd.print("FAN ON");
  delay(50);
  lcd.setCursor(0,1);
  lcd.print("Speed: Level");
  lcd.print(a);
  lcd.print("   ");
  delay(50);
}


void templateNorm()
{
  lcd.setCursor(0,0);
  lcd.print("TEMPR:");
  delay(50);
  lcd.setCursor(8,0);
  lcd.print("C");
  delay(50);
  lcd.setCursor(10,0);
  lcd.print("NORM  ");
  delay(50);
  lcd.setCursor(0,1);
  lcd.print("MTR,HTR OFF     ");
  delay(50);
}


void templateHtr(int b)
{
  lcd.setCursor(0,0);
  lcd.print("TEMPR:");
  delay(50);
  if(b==2)
  {
    lcd.print(" ");
  lcd.setCursor(7,0);
  lcd.print(tempr);
  lcd.print("C ");
  }
 if(b==1)
 {
  lcd.setCursor(6,0); 
  lcd.print(tempr);
  lcd.setCursor(8,0);
  lcd.print("C ");
 }
  delay(50);
  lcd.setCursor(10,0);
  lcd.print("HTR ON");
  delay(50);
  lcd.setCursor(0,1);
  lcd.print("Heating: Level");
  lcd.print(b);
  lcd.print(" ");
  delay(50);
}


void turnhtrOff()
{
  digitalWrite(htrPin1,LOW);
  digitalWrite(htrPin2,LOW);
}




The arduino IDE's .ino source file, proteus isis files and .jpg files can be downloaded in the form of a single .rar archive by clicking here.

Be sure that you have done following:
i. Installed Arduino IDE
ii.Proteus ISIS
Also in order to run simulation in proteus:
i.Download the Arduino library for proteus.
ii. You must copy the location of hex file from Arduino IDE into the proteus model. 

Monday, April 21, 2014

'You've got to find what you love,' Jobs says

This is a prepared text of the Commencement address delivered by Steve Jobs, CEO of Apple Computer and of Pixar Animation Studios, on June 12, 2005.(Source: Stanford University Website)
I am honored to be with you today at your commencement from one of the finest universities in the world. I never graduated from college. Truth be told, this is the closest I've ever gotten to a college graduation. Today I want to tell you three stories from my life. That's it. No big deal. Just three stories.
The first story is about connecting the dots.
I dropped out of Reed College after the first 6 months, but then stayed around as a drop-in for another 18 months or so before I really quit. So why did I drop out?
It started before I was born. My biological mother was a young, unwed college graduate student, and she decided to put me up for adoption. She felt very strongly that I should be adopted by college graduates, so everything was all set for me to be adopted at birth by a lawyer and his wife. Except that when I popped out they decided at the last minute that they really wanted a girl. So my parents, who were on a waiting list, got a call in the middle of the night asking: "We have an unexpected baby boy; do you want him?" They said: "Of course." My biological mother later found out that my mother had never graduated from college and that my father had never graduated from high school. She refused to sign the final adoption papers. She only relented a few months later when my parents promised that I would someday go to college.
And 17 years later I did go to college. But I naively chose a college that was almost as expensive as Stanford, and all of my working-class parents' savings were being spent on my college tuition. After six months, I couldn't see the value in it. I had no idea what I wanted to do with my life and no idea how college was going to help me figure it out. And here I was spending all of the money my parents had saved their entire life. So I decided to drop out and trust that it would all work out OK. It was pretty scary at the time, but looking back it was one of the best decisions I ever made. The minute I dropped out I could stop taking the required classes that didn't interest me, and begin dropping in on the ones that looked interesting.
It wasn't all romantic. I didn't have a dorm room, so I slept on the floor in friends' rooms, I returned coke bottles for the 5¢ deposits to buy food with, and I would walk the 7 miles across town every Sunday night to get one good meal a week at the Hare Krishna temple. I loved it. And much of what I stumbled into by following my curiosity and intuition turned out to be priceless later on. Let me give you one example:
Reed College at that time offered perhaps the best calligraphy instruction in the country. Throughout the campus every poster, every label on every drawer, was beautifully hand calligraphed. Because I had dropped out and didn't have to take the normal classes, I decided to take a calligraphy class to learn how to do this. I learned about serif and san serif typefaces, about varying the amount of space between different letter combinations, about what makes great typography great. It was beautiful, historical, artistically subtle in a way that science can't capture, and I found it fascinating.
None of this had even a hope of any practical application in my life. But ten years later, when we were designing the first Macintosh computer, it all came back to me. And we designed it all into the Mac. It was the first computer with beautiful typography. If I had never dropped in on that single course in college, the Mac would have never had multiple typefaces or proportionally spaced fonts. And since Windows just copied the Mac, it's likely that no personal computer would have them. If I had never dropped out, I would have never dropped in on this calligraphy class, and personal computers might not have the wonderful typography that they do. Of course it was impossible to connect the dots looking forward when I was in college. But it was very, very clear looking backwards ten years later.
Again, you can't connect the dots looking forward; you can only connect them looking backwards. So you have to trust that the dots will somehow connect in your future. You have to trust in something — your gut, destiny, life, karma, whatever. This approach has never let me down, and it has made all the difference in my life.
My second story is about love and loss.
I was lucky — I found what I loved to do early in life. Woz and I started Apple in my parents garage when I was 20. We worked hard, and in 10 years Apple had grown from just the two of us in a garage into a $2 billion company with over 4000 employees. We had just released our finest creation — the Macintosh — a year earlier, and I had just turned 30. And then I got fired. How can you get fired from a company you started? Well, as Apple grew we hired someone who I thought was very talented to run the company with me, and for the first year or so things went well. But then our visions of the future began to diverge and eventually we had a falling out. When we did, our Board of Directors sided with him. So at 30 I was out. And very publicly out. What had been the focus of my entire adult life was gone, and it was devastating.
I really didn't know what to do for a few months. I felt that I had let the previous generation of entrepreneurs down - that I had dropped the baton as it was being passed to me. I met with David Packard and Bob Noyce and tried to apologize for screwing up so badly. I was a very public failure, and I even thought about running away from the valley. But something slowly began to dawn on me — I still loved what I did. The turn of events at Apple had not changed that one bit. I had been rejected, but I was still in love. And so I decided to start over.
I didn't see it then, but it turned out that getting fired from Apple was the best thing that could have ever happened to me. The heaviness of being successful was replaced by the lightness of being a beginner again, less sure about everything. It freed me to enter one of the most creative periods of my life.
During the next five years, I started a company named NeXT, another company named Pixar, and fell in love with an amazing woman who would become my wife. Pixar went on to create the worlds first computer animated feature film, Toy Story, and is now the most successful animation studio in the world. In a remarkable turn of events, Apple bought NeXT, I returned to Apple, and the technology we developed at NeXT is at the heart of Apple's current renaissance. And Laurene and I have a wonderful family together.
I'm pretty sure none of this would have happened if I hadn't been fired from Apple. It was awful tasting medicine, but I guess the patient needed it. Sometimes life hits you in the head with a brick. Don't lose faith. I'm convinced that the only thing that kept me going was that I loved what I did. You've got to find what you love. And that is as true for your work as it is for your lovers. Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven't found it yet, keep looking. Don't settle. As with all matters of the heart, you'll know when you find it. And, like any great relationship, it just gets better and better as the years roll on. So keep looking until you find it. Don't settle.
My third story is about death.
When I was 17, I read a quote that went something like: "If you live each day as if it was your last, someday you'll most certainly be right." It made an impression on me, and since then, for the past 33 years, I have looked in the mirror every morning and asked myself: "If today were the last day of my life, would I want to do what I am about to do today?" And whenever the answer has been "No" for too many days in a row, I know I need to change something.
Remembering that I'll be dead soon is the most important tool I've ever encountered to help me make the big choices in life. Because almost everything — all external expectations, all pride, all fear of embarrassment or failure - these things just fall away in the face of death, leaving only what is truly important. Remembering that you are going to die is the best way I know to avoid the trap of thinking you have something to lose. You are already naked. There is no reason not to follow your heart.
About a year ago I was diagnosed with cancer. I had a scan at 7:30 in the morning, and it clearly showed a tumor on my pancreas. I didn't even know what a pancreas was. The doctors told me this was almost certainly a type of cancer that is incurable, and that I should expect to live no longer than three to six months. My doctor advised me to go home and get my affairs in order, which is doctor's code for prepare to die. It means to try to tell your kids everything you thought you'd have the next 10 years to tell them in just a few months. It means to make sure everything is buttoned up so that it will be as easy as possible for your family. It means to say your goodbyes.
I lived with that diagnosis all day. Later that evening I had a biopsy, where they stuck an endoscope down my throat, through my stomach and into my intestines, put a needle into my pancreas and got a few cells from the tumor. I was sedated, but my wife, who was there, told me that when they viewed the cells under a microscope the doctors started crying because it turned out to be a very rare form of pancreatic cancer that is curable with surgery. I had the surgery and I'm fine now.
This was the closest I've been to facing death, and I hope it's the closest I get for a few more decades. Having lived through it, I can now say this to you with a bit more certainty than when death was a useful but purely intellectual concept:
No one wants to die. Even people who want to go to heaven don't want to die to get there. And yet death is the destination we all share. No one has ever escaped it. And that is as it should be, because Death is very likely the single best invention of Life. It is Life's change agent. It clears out the old to make way for the new. Right now the new is you, but someday not too long from now, you will gradually become the old and be cleared away. Sorry to be so dramatic, but it is quite true.
Your time is limited, so don't waste it living someone else's life. Don't be trapped by dogma — which is living with the results of other people's thinking. Don't let the noise of others' opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.
When I was young, there was an amazing publication called The Whole Earth Catalog, which was one of the bibles of my generation. It was created by a fellow named Stewart Brand not far from here in Menlo Park, and he brought it to life with his poetic touch. This was in the late 1960's, before personal computers and desktop publishing, so it was all made with typewriters, scissors, and polaroid cameras. It was sort of like Google in paperback form, 35 years before Google came along: it was idealistic, and overflowing with neat tools and great notions.
Stewart and his team put out several issues of The Whole Earth Catalog, and then when it had run its course, they put out a final issue. It was the mid-1970s, and I was your age. On the back cover of their final issue was a photograph of an early morning country road, the kind you might find yourself hitchhiking on if you were so adventurous. Beneath it were the words: "Stay Hungry. Stay Foolish." It was their farewell message as they signed off. Stay Hungry. Stay Foolish. And I have always wished that for myself. And now, as you graduate to begin anew, I wish that for you.
Stay Hungry. Stay Foolish.
Thank you all very much.

Tuesday, December 10, 2013

Program in C to find sum and product of two matrices by passing array to function

#include<stdio.h>
void arr(int a[3][3],int b[3][3]);
void main()
{
int a[3][3],b[3][3],c[3][3],d[3][3],i,j;
printf("Enter first matrix\n");
for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
    {
    scanf("%d",&a[i][j]);
    }
   }
printf("You have entered first matrix as\n");
for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
    {
    printf("%d",a[i][j]);
    }
    printf("\n");
   }

printf("Enter second matrix\n");
for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
    {
    scanf("%d \t",&b[i][j]);
    }
  }

printf("You have entered second matrix as\n");
for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
    {
    printf("%d",b[i][j]);
    }
    printf("\n");
   }
arr(a,b);

}


void arr(int a[3][3],int b[3][3])
{
int sum,k,c[3][3],d[3][3],i,j;
 for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
    c[i][j]=a[i][j]+b[i][j];
   }
printf("The sum is\n");
for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
    {
    printf("%d",c[i][j]);
    }
    printf("\n");
   }


    for ( i= 0 ; i < 3 ; i++ )
    {
      for ( j = 0 ; j< 3 ; j++ )
      {
        sum=0;
        for ( k = 0 ; k < 3 ; k++ )
        {
          sum = sum + a[i][k]*b[k][j];
        }
        d[i][j] = sum;

      }
    }


  printf("The Product is\n");
for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
    {
    printf("%d",d[i][j]);
    }
    printf("\n");
   }
}