EmbLogic's Blog

Author Archives: Sagar Chauhan

Multiple Data Compression Program Upto Code Length

#include<stdio.h> #include<stdlib.h> #include<fcntl.h> int open_file(char *); int creat_masterarray(int ); int find_loc(char , char *, int); int code_length(int ); int open_file(char *filename) { int fd; fd = open(filename,O_RDONLY); if(fd<0) { perror(“open”); goto OUT; } printf(“File Opened Successfully. fd = %d\n”,fd); return … Continue reading

Posted in Uncategorized | Leave a comment

A Program that reads integers untill 0 is entered. after input terminates, the program report the total number of even integers (excluding 0) entered,the average value of the even integers,the total number of odd integers entered , and the value of the odd integers.

#include<stdio.h> int main() { int n,even=0,odd=0; float sumodd=0,sumeven=0; scanf(“%d”,&n); while(n!=0) { if(n%2==0) { even++; sumeven=sumeven+n; } else { odd++; sumodd=sumodd+n; } scanf(“%d”,&n); } printf(“\nTotal even num are %d nd Their Average is %f    \n “, even, sumeven/even ); printf(“Total odd  … Continue reading

Posted in Uncategorized | Leave a comment

Nested Structures Ft. Pointer

#include<stdio.h> #include<stdlib.h> struct disfeet { int *f; }; struct distance { struct disfeet *d; }; int main() { struct distance *d1; d1=(struct distance *)malloc(sizeof(struct distance)); d1->d=(struct disfeet *)malloc(sizeof(struct disfeet)); d1->d->f=(int *)malloc(sizeof(int)); printf(“enter distance\n”); scanf(“%d”,&d1->d->f); printf(“distance is %d feet.\n\n”,d1->d->f); return 0; … Continue reading

Posted in Uncategorized | Leave a comment