Thursday, 19 October 2017

Compile time vs Run time error

Compile time
1.      The program need not satisfy any invariants. In fact, it needn't be a well-formed program at all. You could feed this HTML to the compiler and watch it barf...
2.      What can go wrong at compile time:
·         Syntax errors
·         Type checking errors
·         (Rarely) compiler crashes
3.      If the compiler succeeds, what do we know?
·         The program was well formed---a meaningful program in whatever language.
·         It's possible to start running the program. (The program might fail immediately, but at least we can try.)
4.      What are the inputs and outputs?
·         Input was the program being compiled, plus any header files, interfaces, libraries, or other voodoo that it needed to import in order to get compiled.
·         Output is hopefully assembly code or relocatable object code or even an executable program. Or if something goes wrong, output is a bunch of error messages.
Run time
1.      We know nothing about the program's invariants---they are whatever the programmer put in. Run-time invariants are rarely enforced by the compiler alone; it needs help from the programmer.
2.      What can go wrong are run-time errors:
·         Division by zero
·         Dereferencing a null pointer
·         Running out of memory
Also there can be errors that are detected by the program itself:
·         Trying to open a file that isn't there
·         Trying find a web page and discovering that an alleged URL is not well formed
3.      If run-time succeeds, the program finishes (or keeps going) without crashing.
4.      Inputs and outputs are entirely up to the programmer. Files, windows on the screen, network packets, jobs sent to the printer, you name it. If the program launches missiles, that's an output, and it happens only at run time :-)

 Example compile time error

Wednesday, 18 October 2017

Array vs Link List




Sr No.
Array
Link List
1
An array is a collection of similar data type
A link list a collection of similar objects which may have array
2
Space allocation continuous
Space allocation random
3
Element of an array is access through its index
Data of link list access through self-referential pointer

Monday, 16 October 2017

Matrix Diagonal Sum

Q : Write a ‘C’ program to find out sum of diagonal elements of a matrix using ‘C’.

Solution : 

#include<stdio.h>
#include<conio.h>
#define MAX 3
void main()
{
     int ar[MAX][MAX],i,j,r,c,sum=0;
     clrscr();
     for(r=0;r<MAX;r++)
     {
          for(c=0;c<MAX;c++)
          {
              printf("Enter Number>> ");
              scanf("%d",&ar[r][c]);
          }
     }
     printf("\n\tOutput\n\n");
     for(r=0;r<MAX;

Saturday, 14 October 2017

LATITUDE LONGITUDE Finder

LATITUDE LONGITUDE Finder banner

<!DOCTYPE html>
<html>
<head>
    <title>Girfa</title>
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
</head>
<body>
    <input id="searchInput" class="input-controls" type="text" placeholder="Enter a location">
    <div class="map" id="map" style="width: 100%; height: 300px;"></div>
    <div class="form_area">
        <input type="text" name="location" id="location">
        <input type="text" name="lat" id="lat">
        <input type="text" name="lng" id="lng">
    </div>
    <script>
        /* script */