Skip to main content

Posts

Showing posts from September, 2014

Mahalaya

Mahalaya marks the start of the ' Devipaksha ' and the end of the ' Pitri-paksha '. The traditional six day countdown to Mahasaptami starts from Mahalaya. Goddess Durga visits the earth for only four days but seven days prior to the Pujas, starts the Mahalaya. The enchanting voice of Birendra Krishna Bhadra fills up the predawn hours of the day thus marking the beginning of "Devipaksha" and the beginning of the count-down to Durga Puja.  Myth regarding Mahalaya:  Pitri- Paksha is a 16 day period during which Hindus pay homage to their ancestors. As per legend, when Karna died in the epic Mahabharata, his soul transcended to heaven. There he was offered jewelry as food. Bemused, Karna asked Indra for the reason of this bizarre happening. Indra told him that because of the fact that he has never donated food to his ancestors in Shraddhas, during his lifetime, he was getting such treatment. Karna said that he was unaware of his ancestors and hence he had no c

HokKolorob

The Jadavpur University campus continued to simmer on Thursday, a day after a series of protests, as students of all departments decided to boycott classes. “We have decided not to attend classes till the vice chancellor Abhijit Chakraborty resigns,” said Disha Roychowdhury, one of the protesting students. Another second year Production Engineering student said that at least the VC should have come up with an apology over the attack on students by police under his instructions. Members of Students Federation of India (SFI), however, said they were not a part of the class boycott programme. “We have called for a day-long students strike and not class boycott. That is the unanimous decision of the students here,” said Debojyoti Das, state secretary, SFI. The university authorities, on the other hand, in a bid to pacify the students had instructed the posters which were put up on Wednesday, to be torn off the university walls. “It had actually backfired. When I went to take off the poster

C Program to Implement Heap Sort

Algorithm: hs( a[], n)  {   heap(a,n);   for (i = n to 1)    {     temp<-a[1];     a[1]<-a[i];     a[i]<-temp;     downheap(a,1,i-1);    }  } heap(a[],n)  {   index <- n/2;   for(i= index to 1)     downheap(a,i,n);  } downheap(heap[], root, leaf)  {   lc<-2*root;   rc<-lc+1;   if(lc<=leaf)    {     max<-heap[lc];     index<-lc;     if(rc<=leaf)     {      if(heap[rc]>max)      {       max<-heap[rc];       index<-rc;      }     }     if(heap[root] < heap[index])      {       temp <- heap[root];       heap[root] <- heap[index];       heap[index] <- temp;       downheap(heap,index,leaf);      }    } } Program #include<stdio.h> #include<conio.h> void heap ( int * , int ); void downheap ( int * , int , int ); void hs ( int * , int ); void main () { int a [ 20 ], i , n ; clrscr (); printf ( "Enter the number of Elements:" ); scanf ( "%d" , & n ); printf ( "Enter the elements: \n &qu

Write a C Program to find the number of data in a linked list

#include <stdio.h> #define newnode (struct node*)malloc(sizeof(struct node)) typedef struct node { int data ; struct node * next ; } node ; node * create_list (); void main () { node * f ; int len ; f = NULL ; f = create_list (); len = find_len ( f ); printf ( " \n length = %d" , len ); } // main node * create_list () { node * f , * c , * p ; int tdata ; f = NULL ; printf ( " \n Enter data ( use 0 to exit ) : " ); scanf ( "%d" , & tdata ); while ( tdata != 0 ) { c = newnode ; if ( c == NULL ) { printf ( " \n Insuf. mem. " ); exit ( 0 ); } c -> data = tdata ; c -> next = NULL ; if ( f == NULL ) f = c ; else p -> next = c ; p = c ; printf ( " \n Enter data ( use 0 to exit ) : " ); scanf ( "%d" , & tdata ); } //while return ( f ); } // create list int find_len ( node * f ) { int len = 0 ; node * t

Write a Program in C++ to find the Factorial of a Number

/*ITERATIVE*/ //Calling the Header File. #include<iostream> //Declaring the main function int main () { //Tells the compiler that we'll be using all the standard C++ library functions using namespace std ; int num , factorial = 1 ; //Ask for the number. cout << "Enter a number to calculate it's factorial" << endl ; cin >> num ; for ( int i = 1 ; i <= num ; i ++ ) { factorial = factorial * i ; } cout << "Factorial of " << num << "=" << factorial << endl ; cin . get (); return 0 ; } /*RECURSION */ # include < iostream > using namespace std ; int fact ( int ); int main (){ int num , f ; cout << " \n Enter a number: " ; cin >> num ; f = fact ( num ); cout << " \n Factorial of " << num << " is: " << f ; return 0 ; } //recursive function int

Calculate Depreciation using C

#include<conio.h> #include<stdio.h> void main () { float sv , pv , dep ; int yos ; clrscr (); printf ( "Enter the purchase value :- " ); scanf ( "%f" , & pv ); printf ( "Enter the year of service :- " ); scanf ( "%d" , & yos ); printf ( "Enter the value of depreation :- " ); scanf ( "%f" , & dep ); sv = pv - ( dep * yos ); printf ( " \n The salvage value equal to :- %f" , sv ); getch (); } /* Summary: Compute the yearly depreciation of the value of an item, given by Depreciation = (PURCHASE VALUE - SALVAGE VALUE) / YEAR OF SERVICE */

Decimal to Octal Conversion using C

#include<stdio.h> int main (){ long int decimalNumber , remainder , quotient ; int octalNumber [ 100 ], i = 1 , j ; printf ( "Enter any decimal number: " ); scanf ( "%ld" , & decimalNumber ); quotient = decimalNumber ; while ( quotient != 0 ){ octalNumber [ i ++ ] = quotient % 8 ; quotient = quotient / 8 ; } printf ( "Equivalent octal value of decimal number %d: " , decimalNumber ); for ( j = i - 1 ; j > 0 ; j -- ) printf ( "%d" , octalNumber [ j ]); return 0 ; } /* Summary: Converts decimal which is base 10 number system which uses the digits from 0 - 9 to octal which is base 8 number system which uses the digits from 0 to 7. */

Decimal to Hexadecimal Conversion

#include<stdio.h> #include<conio.h> #include<math.h> void main () { long int num ; clrscr (); printf ( "Enter the decimal number : " ); scanf ( "%ld" , & num ); long int rem [ 50 ], i = 0 , length = 0 ; while ( num > 0 ) { rem [ i ] = num % 16 ; num = num / 16 ; i ++ ; length ++ ; } printf ( "Hexadecimal number : " ); for ( i = length - 1 ; i >= 0 ; i -- ) { switch ( rem [ i ]) { case 10 : printf ( "A" ); break ; case 11 : printf ( "B" ); break ; case 12 : printf ( "C" ); break ; case 13 : printf ( "D" ); break ; case 14 : printf ( "E" ); break ; case 15 : printf ( "F" ); break ; default : printf ( "%ld" , rem [ i ]); } } getch (); } /* Summary: Converts decimal number which is base 10 number system 0-9 to hexadecimal which uses the digits from 0 to 9 and A, B,

Decimal to Binary Conversion

#include<stdio.h> int main (){ long int decimalNumber , remainder , quotient ; int binaryNumber [ 100 ], i = 1 , j ; printf ( "Enter any decimal number: " ); scanf ( "%ld" , & decimalNumber ); quotient = decimalNumber ; while ( quotient != 0 ){ binaryNumber [ i ++ ] = quotient % 2 ; quotient = quotient / 2 ; } printf ( "Equivalent binary value of decimal number %d: " , decimalNumber ); for ( j = i - 1 ; j > 0 ; j -- ) printf ( "%d" , binaryNumber [ j ]); return 0 ; } /* Summary: Converts decimal number which is base 10 number system 0-9 to binary which is base 2 number system 0 and 1. */

Write a C Program to compare two strings

#include <stdio.h> #include <string.h> int main () { char a [ 100 ], b [ 100 ]; printf ( "Enter the first string \n " ); gets ( a ); printf ( "Enter the second string \n " ); gets ( b ); if ( strcmp ( a , b ) == 0 ) printf ( "Entered strings are equal. \n " ); else printf ( "Entered strings are not equal. \n " ); return 0 ; } /* Summary: Compares two string for equality */

CockTail Sort

#include <stdio.h> #define MAX 8 int main () { int data [ MAX ]; int i , j , n , c ; printf ( " \n Enter the data" ); for ( i = 0 ; i < MAX ; i ++ ) { scanf ( "%d" , & data [ i ]); } n = MAX ; do { /*Rightward pass will shift the largest element to its correct place at the end*/ for ( i = 0 ; i < n - 1 ; i ++ ) { if ( data [ i ] > data [ i + 1 ]) { data [ i ] = data [ i ] + data [ i + 1 ]; data [ i + 1 ] = data [ i ] - data [ i + 1 ]; data [ i ] = data [ i ] - data [ i + 1 ]; } } n = n - 1 ; /* Leftward pass will shift the smallest element to its correct place at the beginning*/ for ( i = MAX - 1 , c = 0 ; i >= c ; i -- ) { if ( data [ i ] < data [ i - 1 ]) { data [ i ] = data [ i ] + data [ i - 1 ]; data [ i - 1 ] = data [ i ] - data [ i - 1 ]; data [ i ] = data [ i ] - data [ i - 1 ];