Problem Stament in CN Lab Manual
-
Upload
kande-archana-k -
Category
Documents
-
view
5 -
download
0
description
Transcript of Problem Stament in CN Lab Manual
Week 11. To the given bits add the string 01111110 to both the starting and the end of the string2. To add 0 to each set of 5 ones i.e. after every five consecutive 1s appear a zero1. Program:
#include "stdio.h"#include "conio.h"int main(){int i=0,count=0;char a[100];printf("enter the bits : ");scanf("%s",a); printf("\nAfter bit stuffing \n");printf("01111110"); for(i=0;a[i]; i++){ if(a[i]=='1') count++; else count=0;printf("%c",a[i]);if(count==5) { printf("0"); count=0; }}printf("01111110");getch();return 1;}
C program to convert a decimal number to its equivalent Bits format.2. Program #include #include void main(){unsigned long dec;int a[25],c=0,i;clrscr();printf("\nENTER A DECIMAL NUMBER: ");scanf("%lu",&dec);printf("\n%lu IN BITS FORMAT: ",dec);while(dec>0){a[c]=dec%2;dec=dec/2;c++;}for(i=c-1;i>=0;i--)printf("%d",a[i]);getch();}
Output
Enter a decimal number 44 in bit format : 100Search a key number within n given numbers using pointers3. Program #include #include #include void main(){int n,*p,i,num,flag=0;clrscr();printf("\nHOW MANY NUMBER: ");scanf("%d",&n);p=(int *) malloc(n*2);if(p==NULL){printf("\nMEMORY ALLOCATION UNSUCCESSFUL");exit();}for(i=0;i