Friday, May 11, 2012

Program to check that entered no is divisible by 10 or not.


//program to check that entered no is divisible by 10 or not.
#include<stdio.h>
#include<conio.h>
main()
{ int n,r,s,i;
 printf("Enter the no ");
 scanf("%d",&n);
 s=0;
for(i=0;i<1;i++)
 { r=n%10;
  n=n/10;
 }
 if(r==0)
 printf("Entered no is divisible by 10");
 else
 printf("Entered no is Not divisible by 10");
getch();
}

Thursday, May 3, 2012

Program to check that entered no is divisible by 3 or not.


//program to check that entered no is divisible by 3 or not.
#include<stdio.h>
#include<conio.h>
main()
{ int n,r,s;
 printf("Enter the no ");
 scanf("%d",&n);
 s=0;
 while(r!=0)
 { r=n%10;
  n=n/10;
  s=s+r;
 }
 if(s%3==0)
 printf("Entered no is divisible by 3");
 else
 printf("Not divisible by 3");
getch();
}

Sunday, March 18, 2012

Program To print the two dimensional array.

//To print the two dimensional array.
#include<stdio.h>
#include<conio.h>
main()
{
      int a[3][3],i,j;
      printf("Enter the value of 3X3 array:-");
      for(i=0;i<3;i++)
      {
         for(j=0;j<3;j++)
          { scanf("%d",&a[i][j]);
          }
      } 
        printf("The 2D array is :");
        for(i=0;i<3;i++)
        { printf("\n\n");
         for(j=0;j<3;j++)
          { printf("%d  ",a[i][j]);
          }
        } 
        getch();
 }
          

To print the reverse of character.

//To print the reverse of character.
#include<stdio.h>
#include<conio.h>
main()
{     int i;
      char a[5];
      printf("Enter the name- ");
      for(i=0;i<5;i++)
      scanf("%c",&a[i]);
      printf("Your name is: ");
      for(i=0;i<5;i++)
      printf("%c",a[i]);
      printf("\nYour reverse  name is: ");
      for(i=4;i>=0;i--)
      printf("%c",a[i]);
      getch();
      }

Program To take character from the user by array .

//To take character from the user by array .
#include<stdio.h>
#include<conio.h>
main()
{     int i;
      char a[5];
      printf("Enter the name ");
      for(i=0;i<=4;i++)
      scanf("%c",&a[i]);
      printf("Your name is ");
      for(i=0;i<=4;i++)
      printf("%c",a[i]);
      getch();
      }

Saturday, March 17, 2012

Program for identify +ve and -ve no in an array .

Program for identify +ve and -ve no in an array .


#include<stdio.h>
#include<conio.h>
 main()
{
 int n[15],m,e,i;
 m=n[0];
 printf("Enter the 10 no ");
 for(i=0;i<10;i++)
 {
  scanf("%d",&n[i]);
 }

  printf("\nThe positive no are:\n");
  for(i=0;i<10;i++)
  {
   if(n[i]>0)
   {
    printf("%d,",n[i]);
   }
  }
  printf("\nThe negative no are:\n");
  for(i=0;i<10;i++)
  {
   if(n[i]<0)
   {
    printf("%d,",n[i]);
   }
  }
  getch();
}

Program to find odd and even nos. in an array.

//Program to find odd and even nos. in an array.
#include<stdio.h>
#include<conio.h>
 main()
{
 int n[10],i;
 printf("Enter the 10 no ");
 for(i=0;i<10;i++)
 {
  scanf("%d",&n[i]);
 }
   printf("The even nos: ");
  for(i=0;i<10;i++)
  {
   if(n[i]%2==0)
   {  
    printf("%d,",n[i]);
   }
         }
   printf("\nThe odd nos : ");
   for(i=0;i<10;i++)
   {
   if(n[i]%2!=0)
    { //o[i]=n[i];
   printf("%d,",n[i]);
    }
  
  }

                         
  getch();
}