Tuesday, 4 November 2014

Write a ‘C’ program to Read an array of 20 elements and then send all negative elements of the array to the end without altering the original sequence.


#include<stdio.h>
void del_pos(int a[],int n,int p)
{
        int i;
        for(i=p;i<n-1;i++)
        {
                a[i]=a[i+1];
        }
}
main()
{
        int a[100],i,j,n,ele,temp;
        printf("\nEnter how many terms=");
        scanf("%d",&n);
        printf("\nEnter the elements=");
        for(i=0;i<n;i++)
        {
                scanf("%d",&a[i]);
        }
        printf("\nThe elements are=");
        for(i=0;i<n && a[i]>=0;i++)
        {
                printf("%d ",a[i]);
        }
        printf("\nAfter sending negative elements to the end");
        i=0;
        while(a[i]<0)
        {
                if(a[i]<0)
                {
                        temp=a[i];
                        del_pos(a,n,i);
                        a[n-1]=temp;
                }
                if(a[i]<0)
                        continue;
                i++;
        }
        printf("\n");
        for(j=0;j<n;j++)
        {
                printf("%d ",a[j]);
        }
}

Friday, 31 October 2014

Write a program to find length of a string using library function.

#include<stdio.h>
#include<string.h>
main()
{
    char str[100];
    printf("\nEnter a string=");
    scanf("%s",str);
    printf("\nLength of the string=%d",strlen(str));
}

Write a program to reverse a string using library function.

#include<stdio.h>
#include<string.h>
main()
{
    char str[100];
    printf("\nEnter a string=");
    scanf("%s",str);
    printf("\nAfter reversing the resultant string=%s",strrev(str));
}

Write a program to concanate two strings using library function.

#include<stdio.h>
#include<string.h>
main()
{
    char str1[100],str2[100];
    printf("\nEnter first string=");
    scanf("%s",str1);
    printf("\nEnter second string=");
    scanf("%s",str2);
    strcat(str1,str2);
    printf("\nAfter concatanation the resultant string=%s",str1);
}

Wednesday, 29 October 2014

CAO

    Addressing modes:    The Different ways in which the location of an operand is specified in an instruction are referred to as addressing modes.

    Register mode:    The operand is the content of a processor register; the name (address) of the register is given in the instruction.

Programming and Data Structures

Any AVL tree with n nodes has height less than 1.44logn.

Monday, 20 October 2014

Write a shall program to add two integers.

clear
echo -n "Enter two integers="
read a
read b
c=`expr $a + $b`
echo -n "The sum is $c"