EmbLogic's Blog

Category Archives: Data Structures with C

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

Write a program to reverse a number?

CODE: #include<stdio.h> int main() { int n,r=0,num; printf(“Enter a number:\n”); scanf(“%d”,&n); num=n; while(n!=0) { r=r*10; r=r+n%10; n=n/10; } printf(“Reverse number is %d\n”,r); if(num==r) printf(“Palindrome number\n”); else printf(“Not a Palindrome\n”); return 0; }

Posted in Data Structures with C | Leave a comment

Write a program to print Diamond Pattern?

CODE: #include<stdio.h> int main() { int i,j,k,n,space,temp; printf(“enter value of n\n”); scanf(“%d”,&n); temp=n; for(i=1;i<=n;i++) { for(j=i;j<n;j++) { printf(” “); } for(k=1;k<(2*i);k++) { printf(“*”); } printf(“\n”); } temp=1; for(i=n-1;i>=1;i–) { for(j=1;j<=temp;j++) { printf(” “); } temp++; for(k=1;k<(i*2);k++) { printf(“*”); } printf(“\n”); … Continue reading

Posted in Data Structures with C | Leave a comment

Write a program to find the range of data types?

CODE: #include<stdio.h> #include<limits.h> #include<float.h> int main() { printf(“Range of integer value:%d to %d \n”,INT_MIN,INT_MAX); printf(“Range of char value:%d to %d \n”,CHAR_MIN,CHAR_MAX); printf(“Range of float value:%e to %e \n”,FLT_MIN,FLT_MAX); printf(“Range of double value:%e to %e \n”,DBL_MIN,DBL_MAX); printf(“Range of long double value:%e … Continue reading

Posted in Data Structures with C | Leave a comment

Write a program to find LCM and HCF of three number?

CODE: #include<stdio.h> int main() { int a,b,c,x,y,z,lcm,hcf,r,lcm1; printf(“Enter three number\n”); scanf(“%d%d%d”,&x,&y,&z); a=x; b=y; c=z; while(x!=0) { r=y%x; y=x; x=r; } lcm=(a*b)/y; while(y!=0) { r=z%y; z=y; y=r; } hcf=z; lcm1=(lcm*c)/hcf; printf(“LCM:%d”,lcm1); printf(“HCF:%d”,hcf); return 0; }

Posted in Data Structures with C | Leave a comment

2 Dimensional Array

CODE : #include<stdio.h> int main() { int **a,**b; int i,j; a=(int **)malloc(sizeof(int)*10); b=(int **)malloc(sizeof(int)*10); for(i=0;i<10;i++) { *(a+i)=(int *)malloc(sizeof(int)*10); *(b+i)=(int *)malloc(sizeof(int)*10); } printf(“Enter Elements of Array is:\n”); for(i=0;i<3;i++) { for(j=0;j<3;j++) { scanf(“%d”,(*(a+i)+j)); } } printf(“Elements are:\n”); for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf(“%d\t”,*(*(a+i)+j)); … Continue reading

Posted in Data Structures with C | Leave a comment

write a program to add two distances in feet and inches?

code : #include<stdio.h> #include<stdlib.h> struct distance { int feet,meter; float inch,cm; }; struct distance display(struct distance d1,struct distance d2,struct distance d3,struct distance d4); struct distance convert(struct distance d3); struct distance addlist(struct distance d1 ,struct distance d2); struct distance input (); … Continue reading

Posted in Data Structures with C | Leave a comment