EmbLogic's Blog

Category Archives: Data Structures with C

write a program for insertion sort?

code: #include<stdio.h> #include<stdlib.h> int insertion_sort(int *,int); int main() { int i,n; int *arr; printf(“Enter No. Of Elements\n”); scanf(“%d”,&n); arr=calloc(n,sizeof(int)); printf(“Elemente Are:\n”); for(i=0;i<n;i++) { scanf(“%d”,arr+i); } insertion_sort(arr,n); printf(“Sorted Elements Are:\n”); for(i=0;i<n;i++) { printf(“%d “,*(arr+i)); } return 0; } int insertion_sort(int *arr,int … Continue reading

Posted in Data Structures with C | Leave a comment

Hash Table RCS logfile

RCS file: deleted.c,v Working file: deleted.c head: 1.2 branch: locks: strict root: 1.2 access list: symbolic names: keyword substitution: kv total revisions: 2;    selected revisions: 2 description: this func deletes the data from the HASH TABLE for a particular key … Continue reading

Posted in Data Structures with C | Tagged | Leave a comment

Calculating size of union without using sizeof operator

  #include”header.h” typedef union floating { int i; char c; long double x; }floatingpoint; int main() { floatingpoint f; int ptr2; int ptr,ptr1; ptr=(int)&f; ptr1=(int)(&f+1); ptr2 =(ptr1-ptr); printf(“size of ptr %d”,ptr); printf(“size of ptr1 %d”,ptr1); printf(“size of union %d”,ptr2); } … Continue reading

Posted in Data Structures with C | Leave a comment

Stack (create,push, pop & display) RCS logfile

RCS file: createstack.c,v Working file: createstack.c head: 1.1 branch: locks: strict root: 1.1 access list: symbolic names: keyword substitution: kv total revisions: 1;    selected revisions: 1 description: this func will create a new stack of size entered by the user … Continue reading

Posted in Data Structures with C | Tagged | Leave a comment

Linklist insertion, deletion, traversing, sorting (bubble & insertion sort) logfile

RCS file: bubblesort.c,v Working file: bubblesort.c head: 1.2 branch: locks: strict root: 1.2 access list: symbolic names: keyword substitution: kv total revisions: 2;    selected revisions: 2 description: this func sort the elements in the lilnlist using bubble sort method —————————- … Continue reading

Posted in Data Structures with C | Tagged | Leave a comment

Linked list

A Linked list is a sequence of data structures connected together via links. Each link in the linked list contains a data element and a connection to the next link. The linked lists are most widely used in the application programming … Continue reading

Posted in Data Structures with C | Tagged | Leave a comment

What is Function Pointer

A function pointer (or subroutine pointer or procedure pointer) is a type of pointer supported by third-generation programming languages (such as PL/I, COBOL, Fortran,[1] dBASE dBL, and C) and object-oriented programming languages (such as C++ and D).[2] Instead of referring … Continue reading

Posted in Data Structures with C | Leave a comment

Different methods of swapping 2 numbers

#include<stdio.h> void swap(int *,int *); int main() { int temp; int *t; int a=100,b=200; //Using 3 variables //1.1 temp = a; a = b; b = temp; printf(“%d %d\n”,a,b); //1.2 swap(&a,&b); printf(“%d %d\n”,a,b); //Using 2 variables //2.1 a += b; … Continue reading

Posted in Data Structures with C | Tagged , , , , | Leave a comment

Errors in “Hello World” program

#include<stdio.h> int main() { printf(“Hello World”); return 0; } /* Errors Line 1 :- *1. If u remove only preprocessor (#)->error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token *2.#nclude<stdio.h> ->  error: invalid preprocessing directive #nclude *3. #include … Continue reading

Posted in Data Structures with C | Tagged , , , , , , | Leave a comment

What is bss (Block Storage Start) ?

The .bss segment stores all uninitialized global, static, and external variables (declared with extern keyword). Global, external, and static variable are by default initialized to zero. This section occupies no actual space in the object file. it is merely a … Continue reading

Posted in Data Structures with C | Leave a comment

Matrix Addition using 2D Array with Pointers

#include #include int main() { int r,c,k; printf(“enter the size of rows\n”); scanf(“%d”,&r); printf(“enter the size of columns\n”); scanf(“%d”,&c); int **a,**b,**d,i,j; a=(int **)malloc(sizeof(int*)*3); if(!a) { perror(“malloc”); goto x; } for(i=0;i<3;i++) *(a+i)=(int *)malloc(sizeof(int)*3); if(!(*(a+i))) { perror("malloc"); goto x; } b=(int **)malloc(sizeof(int*)*3); … Continue reading

Posted in Data Structures with C | Leave a comment

dangling and wild pointer

dandling pointer is a pointer which pointing to non existing memory location. when a object is deleted or de allocated without modifying the value of the pointer that time dangling pointer arise. uninitialized pointer are known as wild pointer beacause … Continue reading

Posted in Data Structures with C | Leave a comment

Write a Program to Subtract two matrix?

code : #include<stdio.h> #include<stdlib.h> int main() { system(“clear”); int r,c,i,j,a[10][10],b[10][10],d[10][10]; printf(“Enter Row\n”); scanf(“%d”,&r); printf(“Enter Column\n”); scanf(“%d”,&c); printf(“Enter Element of Matrix1\n”); for(i=0;i<r;i++) { for(j=0;j<c;j++) { scanf(“%d”,&a[i][j]); } } printf(“Enter Element of Matrix2\n”); for(i=0;i<r;i++) { for(j=0;j<c;j++) { scanf(“%d”,&b[i][j]); } } for(i=0;i<r;i++) { … Continue reading

Posted in Data Structures with C | Leave a comment

Multiple Data Compression Technique

Multiple Data Compression is an iterative technique to compress the text data. RCS file: ./header.h,v Working file: ./header.h head: 1.4 branch: locks: strict root: 1.4 access list: symbolic names: keyword substitution: kv total revisions: 4; selected revisions: 4 description: This … Continue reading

Posted in Data Structures with C, Project 2: Multiple Data Compression and Encryption | Leave a comment

Write a program to find particular no. is power of two or not?

CODE: #include<stdio.h> int main() { int n; printf(“Enter a value\n”); scanf(“%d”,&n); if((n &(n-1))==0) printf(“no. is power of 2\n”); else printf(“no. is not power of 2\n”); return 0; }

Posted in Data Structures with C | Leave a comment