Friday, 30 December 2016

Plot a graph with ORIGIN Pro 8

Monday, 6 January 2014

A PROGRAMM TO PRINT NON REPETED NUMBER IN C

#include<stdio.h>
#include<conio.h>
int main()
{
    int i,j,count;
    int a[]={12,15,11,10,16,12,17,19,18,10};
    printf("Non Repeted number are: ");
    for(i=0;i<10;i++)
    {
                     count=0;
                     for(j=0;j<10;j++)
                     {
                                      if(a[i]==a[j])
                                      {
                                                    count++;
                                      }
                     }
                     if(count==1)
                     {
                                 printf("%d,",a[i]);
                     }
    }
    getch();
    return 0;
}

A PROGRAMM TO PRINT "HISTOGRAM" IN C

#include<stdio.h>
#include<conio.h>
int main()
{
    int i,j;
    int a[10];
    for(i=0;i<10;i++)
    {
                     printf("Enter array %d element between 1-30:",i+1);
                     scanf("%d",&a[i]);
    }
    printf("Histogram\n");
    for(i=0;i<10;i++)
    {
                     printf("%d",a[i]);
                     for(j=0;j<a[i];j++)
                     {
                                        printf("*");
                                     
                     }
                     printf("\n");
    }
    getch();
    return 0;
}

A FUNCTION TO TAKE POWER OF GIVEN NUMBER (BASE AND EXPONENT WILL BE ENTERED BY THE USER).....!!!!!

#include<stdio.h>
int power(int *,int *);
int main()
{
    int base=0,expo=0,pow=0;
    printf("Enter the base number:");
    scanf("%d",&base);
    printf("Enter the exponent:");
    scanf("%d",&expo);
    pow=power(&base,&expo);
    printf("Power of given base is %d",pow);
    getch();
    return 0;
}

int power(int *base,int *expo)
{
    int x,size;
    size=*base;
    for(x=1;x<*expo;x++)
    {
      *base=*base * size;
    }
    return *base;
}

A PROGRAM TO SEARCH A NUMBER FROM ARRAY AND TO SHOW HOW MANY TIMES IT APPEARED....!!!!

#include<stdio.h>
# define size 15
void search(int arr[],int key );

int main()
{
    int array[15]={0};
    int x=0,key;
    printf("Enter the elements of array;");
    for(x=0;x<15;x++)
    {
       scanf("%d",&array[x]);
    }
    printf("Enter the number to be searched:");
    scanf("%d",&key);
   
    search(array,key);             
getch();
return 0;
}
void search(int arr[],int key)
{
     int x=0,count=0;
     for(x=0;x<size;x++)
     {
        if(key==arr[x])
        {
           count++;
        }
     }
     if (count>0)
     printf("The number was found %d times",count);
     else
     printf("The number was not found");
}

PROGRAM TO PRINT HOLLOW DAIMOND....!!!!!

#include<stdio.h>
int main()
{
    int x,y,z;
    int size=10;
    for(x=0;x<10;x++)
    {
       for(z=0;z<size;z++)
       printf(" ");
       size--;
       for(y=0;y<=2*x;y++)
       {
           if(x>0&&x<=9&&y>0&&y<2*x)
           printf(" ");
           else
           printf("*");
       }
       printf("\n");
    }
    size++;
    //for lower half of empty daimond;
      for(x=8;x>=0;x--)
    {
       size++;
       for(z=0;z<size;z++)
       printf(" ");
      
       for(y=0;y<=2*x;y++)
       {
           if(x<=8&&x>0&&y>0&&y<2*x)
           printf(" ");
           else
           printf("*");
       }
       printf("\n");
    }
   
    getch();
    return 0;
}

EXPECTED OUTPUT:

 

HOW TO PRINT A DIMOND IN C

#include<stdio.h>
int main()
{

   int a,b,c,i,j,k,n;
        printf("Enter the (half)size of dimond:\n");
   scanf("%d",&n);

//for the first half of diamond

   for(i=n;i>0;i--)
        {
             for(j=1;j<i;j++)
             {
            printf(" ");
             }
                 for(k=j-1;k<n;k++)
                 {
                    printf("*");
                    printf(" ");
                 }
          printf("\n");
        }

//for the second half of diamond

   for(a=n-1;a>=0;a--)
        {
           for(b=n;b>a;b--)
          {
          printf(" ");
            }
            for(c=0;c<a;c++)
             {
               printf("*");
               printf(" ");
           }
                printf("\n");
        }
       return 0;
}


Sunday, 5 January 2014

TAKE 2 ARRAYS (2D) AND PRINT THERE SUM IN THIRD ONE

#include<stdio.h>
int main()
{
int i,j,k,r,c;
printf("Enter the number of rows of arrys:");
scanf("%d",&r);
printf("Enter the number of colums of arrys:");
scanf("%d",&c);
int a[r][c];
int b[r][c];
printf("\nEnter values of first 2d arrays:\n");
for(i=0;i<r;i++)
{
   for(j=0;j<c;j++)
  {
printf("Enter values of array element for %d row and %d coulm:",i,j);
  scanf("%d",&a[i][j]);
  }
}
printf("\nEnter values for 2nd arry element\n");
for(i=0;i<r;i++)
{
   for(j=0;j<c;j++)
    {
  printf("Enter values of array element for %d row and %d coulm:",i,j);
    scanf("%d",&b[i][j]);
  }
}
printf("\n");
printf("First aaray elements are\n");
for(i=0;i<r;i++)
{
    for(j=0;j<c;j++)
   {
  printf("%3d",a[i][j]);
   }
  printf("\n");
}
printf("Second aaray elements are\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
   {
  printf("%3d",b[i][j]);
   }
printf("\n");
}
printf("\n\n\n");
printf("sum of arry element\n");
for(i=0;i<r;i++)
{
    for(j=0;j<c;j++)
   {
   printf("%3d",a[i][j]+b[i][j]);
   }
   printf("\n");
}
getch();
return 0;

}

Expected output of :


Enter the number of rows of arrys:2
Enter the number of colums of arrys:3

Enter values of first 2d arrays:
Enter values of array element for 0 row and 0 coulm:1
Enter values of array element for 0 row and 1 coulm:2
Enter values of array element for 0 row and 2 coulm:3
Enter values of array element for 1 row and 0 coulm:3
Enter values of array element for 1 row and 1 coulm:2
Enter values of array element for 1 row and 2 coulm:1

Enter values for 2nd arry element
Enter values of array element for 0 row and 0 coulm:1
Enter values of array element for 0 row and 1 coulm:2
Enter values of array element for 0 row and 2 coulm:3
Enter values of array element for 1 row and 0 coulm:3
Enter values of array element for 1 row and 1 coulm:2
Enter values of array element for 1 row and 2 coulm:1

First aaray elements are
  1  2  3
  3  2  1
Second aaray elements are
  1  2  3
  3  2  1



sum of arry element
  2  4  6
  6  4  2


TO FIND THE AVERAGE,BELOW AVERAGE AND ABOVE AVERAGE MARKS OF ENTIRE CLASS USING ARRAY.....!!!!

#include<stdio.h>
int main()
{
  int marks[10]={0};
    int x,sum=0,count1=0,count2=0;
    float average=0;
    printf("Enter the Marks:");
  
    for(x=0;x<10;x++)
    {
        scanf("%d",&marks[x]);
        sum=sum+marks[x];
    }
    average=(float)sum/10;
    for(x=0;x<10;x++)
    if (marks[x]>=average)
    count1++;
    else
    count2++;
    printf("Average marks of entire class is:%.2f\n",average);
    printf("Number of students obtaining average or more marks are:%d\n",count1);
    printf("Number of students obtaining below average marks are:%d",count2);
    getch();
    return 0;
}
                

TO FIND HOW MANY TIMES AND AT WHAT INDEX THE GIVEN NUMBER OCCURED IN A ARRAY....!!!!

#include<stdio.h>
int main()
{
  int array[25]={1,2,4,3,1,6,8,9,5,3,1,4,6,9,7,3,1,5,7,8,0,3,2,5,0};
    int x,count=0,index[]={0},search;
    printf("Enter the number to be searched from above array:");
    scanf("%d",&search);
    for(x=0;x<25;x++)
    {
      
       if(array[x]==search)
       {
       count++;
       printf("Given number is found at the index:%d\n",x);
       }
    }
    if (count==0)
    printf("The Given number was not found");
    else
    printf("The Given number was found %d times\n",count);
    getch();
    return 0;
}