Friday, May 11, 2012
Program to check that entered no is divisible by 5 or not.
//program to check that entered no is divisible by 5 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||r==5)
printf("Entered no is divisible by 5");
else
printf("Entered no is Not divisible by 5");
getch();
}
Program to count number of digits in a number.
// program to count number of digits in a number.
#include<stdio.h>
#include<conio.h>
main()
{
int num,count=0;
printf("Enter a number: ");
scanf("%d",&num);
while(num)
{
num=num/10;
count++;
}
printf("Total digits is: %d",count);
getch();
}
Program to check that entered no is divisible by 9 or not.
//program to check that entered no is divisible by 9 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%9==0)
printf("Entered no is divisible by 9");
else
printf("Entered no is Not divisible by 9");
getch();
}
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();
}
#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();
}
Labels:
Array
Subscribe to:
Posts (Atom)