EmbLogic's Blog

Binary search for sorted arrays of 10 elements

#include<stdio.h>
#define SIZE 10
int main()
{
int i,arr[SIZE],key;
int l=0,h=SIZE-1,m;
printf(“Enter the numbers in array\n”);
for(i=0;i<SIZE;i++)
{
scanf(“%d”,&arr[i]);
}
printf(“Enter the key”);
scanf(“%d”,&key);
while(l<=h)
{
m=(l+h)/2;
if(key==arr[m])
{
printf(“Element %d is found at %d position”,key,m);
break;
}
else if(key<arr[m])
{
h=m-1;
}
else if(key>arr[m])
{
l=m+1;
}
if(l>h)
{
printf(“not found”);
break;
}
}
return 0;
10,3-17       Top
}

Posted in Data Structures with C | Leave a comment

Implementing system call i.e system()

RCS file: uppercase.c,v
Working file: uppercase.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 program is to convert a lower case character to upper case character.
—————————-
revision 1.1    locked by: root;
date: 2015/02/25 09:46:25;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: uppercase.c,v
Working file: uppercase.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 program is to convert a lower case character to upper case character.
—————————-
revision 1.2    locked by: root;
date: 2015/02/25 09:58:01;  author: root;  state: Exp;  lines: +2 -0
It this we are using system call i.e system() to invoke a program inside a running program.
—————————-
revision 1.1
date: 2015/02/25 09:46:25;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

Implementating system call i.e sytem()

RCS file: upper_case.c,v
Working file: upper_case.c
head: 1.1
branch:
locks: strict
	root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;	selected revisions: 1
description:
In this program we have converted the lower case character into upper case character.
----------------------------
revision 1.1	locked by: root;
date: 2015/02/25 09:43:19;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: upper_case.c,v
Working file: upper_case.c
head: 1.2
branch:
locks: strict
	root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;	selected revisions: 2
description:
In this program we have converted the lower case character into upper case character.
----------------------------
revision 1.2	locked by: root;
date: 2015/02/25 09:54:55;  author: root;  state: Exp;  lines: +2 -0
In this we are using system call i.e system() to invoke a program inside a running program .
----------------------------
revision 1.1
date: 2015/02/25 09:43:19;  author: root;  state: Exp;
Initial revision
=============================================================================
Posted in Uncategorized | Leave a comment

lower case character to upper case character

RCS file: uppercase.c,v
Working file: uppercase.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 program is to convert a lower case character to upper case character.
—————————-
revision 1.1    locked by: root;
date: 2015/02/25 09:46:25;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

Lower Case Character into Upper Case Character

RCS file: upper_case.c,v
Working file: upper_case.c
head: 1.1
branch:
locks: strict
	root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;	selected revisions: 1
description:
In this program we have converted the lower case character into upper case character.
----------------------------
revision 1.1	locked by: root;
date: 2015/02/25 09:43:19;  author: root;  state: Exp;
Initial revision
=============================================================================
Posted in Uncategorized | Leave a comment

Computing real roots of quadratic equation.

RCS file: quad.c,v
Working file: quad.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
—————————-
revision 1.1 locked by: root;
date: 2015/02/25 06:22:57; author: root; state: Exp;
Initial revision

Posted in Uncategorized | Leave a comment

Swapping without third variable

#include<stdio.h>
int main()
{
int i,j;
printf(“Enter the value of i:”);
scanf(“%d”,&i);
printf(“Enter the value of j:”);
scanf(“%d”,&j);
i=i+j;
j=i-j;
i=i-j;
printf(“%d”,i);
printf(“%d”,j);
return 0;

}

Posted in Data Structures with C | Leave a comment

To find Largest and Smallest no.s among five numbers entered from the user

#include<stdio.h>
int main()
{
int a,b,c,d,e,largest,smallest;
printf(“enter five integers\n”);
scanf(“%d%d%d%d%d”, &a,&b,&c,&d,&e);
largest = a;
if (b > largest)
{
largest=b;
}
if (c > largest)
{
largest=c;
}
if (d > largest)
{
largest=d;
}
if (e > largest)
{
largest=e;
}
printf(“largest number is  = %d\n”,largest);
smallest = a;
if (b < smallest)
{
smallest=b;
}
if (c < smallest)
{
smallest=c;
}
if (d < smallest)
{
smallest=d;
}
if (e < smallest)
{
smallest=e;
}
printf(“smallest number is  = %d\n”,smallest);
return 0;
}

 

Posted in Data Structures with C | Leave a comment

Successfuly performed 3 bit compression

RCS file: 3bit.c,v
Working file: 3bit.c
head: 1.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 2; selected revisions: 2
description:
THIS IS THE BASE FILE FOR 3 BIT COMPRESSION…..
—————————-
revision 1.2
date: 2015/02/22 17:59:52; author: root; state: Exp; lines: +1 -1
3 BIT COMPRESSION SUCCESSFULLY DONE.
—————————-
revision 1.1
date: 2015/02/22 17:57:24; author: root; state: Exp;
Initial revision
=============================================================================

Posted in Project 2: Multiple Data Compression and Encryption | Leave a comment

Decimal to binary conversion

1 #include <stdio.h>
2 int main()
3 {
4         int i,a,b;
5         printf(“enter a decimal number\n”);
6         scanf(“%d”, &a);
7         for(i=0;i<=32;i++)
8         {
9                 b=a%2;
10                 printf(“binary number is %d\n”, b);
11                 a=a/2;
12         }
13         return 0;
14 }
~
~
~
~
~
~
~
~
~
“bin.c” 14L, 194C                                             11,3-17       All

Posted in Uncategorized | Leave a comment

Successfully found largest and smallest element of array using pointers.

RCS file: 04.c,v
Working file: 04.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 is the base file for our program….
—————————-
revision 1.2 locked by: root;
date: 2015/02/21 11:03:44; author: root; state: Exp; lines: +6 -5
This is the program to find largest and smallest element in array using concept of pointers.
—————————-
revision 1.1
date: 2015/02/21 10:38:27; author: root; state: Exp;
Initial revision
=============================================================================

Posted in Data Structures with C | Leave a comment

C program to sort n number of string.

#include
#include
int main()
{
int b;
int i=0,j=0,k=0;
char *a[10],c,*temp;

printf(“How many string you want to enter:”);
scanf(“%d”,&b);
for(i=0;i<b;i++)
{
a[i]=(char*)malloc(sizeof(char)*20);
}
printf("Enter %d strings\n",b);
for(i=0;i<b;i++)
{
scanf("%s",a[i]);
}
//Algorithm to sort string
for(k=0;k<b;k++)
{
for(i=0;i(*(*(a+i+1)+j)))
{
temp=*(a+i);
*(a+i)=*(a+i+1);
*(a+i+1)=temp;
j=0;
break;
}
if(*(*(a+i)+j)(*(*(a+i+1)+j)))
{
temp=*(a+i);
*(a+i)=*(a+i+1);
*(a+i+1)=temp;
break;
}

}
}
printf(“Sorted string is:\n”);
for(i=0;i<b;i++)
{
printf("%s\n",a[i]);
}
return 0;
}

Posted in Data Structures with C | Leave a comment

A number can be special,larger or it can be special but not scary.

RCS file: special.c,v
Working file: special.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
—————————-
revision 1.1 locked by: root;
date: 2015/02/21 07:40:24; author: root; state: Exp;
Initial revision

Posted in Uncategorized | Leave a comment

fibonacci series

1 #include <stdio.h>
2 int main()
3 {
4         int i=0;
5         int j=1;
6         printf(“%d”, i);
7         printf(” %d”,j);
8         int k,a,sum;
9         for (k=0;k<=10;k++)
10         {
11                 sum=i+j;
12                 a=sum;
13                 i=j;
14                 j=a;
15                 printf(” %d”,sum);
16         }
17 }
~
~
~
~
~
~
~
“fibonacci.c” 17L, 186C                                      7,2-9         All

Posted in Uncategorized | Leave a comment

Area of square & triangle

RCS file: area.c,v
Working file: area.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
—————————-
revision 1.1 locked by: root;
date: 2015/02/21 06:35:32; author: root; state: Exp;
Initial revision

Posted in Data Structures with C | Leave a comment