#include<stdio.h>
int digitcount(int x)
{
int r,c=0,i=0,y=x;
while(x!=0)
{
r=x%10;
x=x/10;
c++;
}
while(y!=0)
{
r=y%10;
y=y/10;
i++;
if(i==c-2)
{
return r;
}
}
}
void primecheck(int p)
{
int count=0,j;
for(j=1;j<=p;j++)
{
if(p%j==0)
{
count++;
}
}
if(count==2)
{
printf("3rd digit i.e. %d is prime.",p);
}
else
{
printf("3rd digit i.e. %d is not prime.",p);
}
}
void main()
{
int n,digino;
printf("Enter the number : ");
scanf("%d",&n);
digino=digitcount(n);
primecheck(digino);
getch();
}
Related Posts:
Copying string 2 to string 1#include<stdio.h>
void copystr(char [],char []);
void main()
{
char str1[50],str2[50];
printf("Enter 1st string,str1 : ");
gets(str1);
printf("\nEnter 2nd string,s… Read More
Code in C to multiply two matrix#include<stdio.h>
void matmultiply(int m[3][3], int n[3][3]);
void read(int x[3][3]);
//void read2(int y[3][3]);
void main()
{
int a[3][3],b[3][3],l,w;
printf("\nFor matrix a :-\n");
&… Read More
Count no. of words in a sentence in C#include<stdio.h>
void main()
{
char str[50],i,wordcount=0;
printf("Enter a line of text : ");
gets(str);
for(i=0;str[i]!='\0';i++)
{
&… Read More
Sorting names in C#include<stdio.h>
//#include<string.h>
void copystring(char txt1[], char txt2[])
{
int k;
for(k=0;txt2[k]!='\0';k++)
{
txt1[k]=txt2[k];
… Read More
Concatenation of two string in C#include<stdio.h>
void catstr(char [],char []);
void main()
{
char str1[50],str2[50];
printf("Enter 1st string (str1) :");
gets(str1);
printf("\nEnter 2nd string (… Read More
0 comments:
Post a Comment