Program in C Language: Number Is Prime Or Not, Print Name 10 Times
1. Program in C language to check whether the number is Prime or not :
# include<stdio h>
# include<conio.h>
void main()
{
int n, i, temp;
clrscr();
printf ( "Enter any number \n");
scanf("%d ,& n );
temp= n/2;
for ( i=2;i<= temp;i++)
}
if ( n % i= = 0)
{
printf("% d is not a prime no.",n);
break;
}
}
if (i = = temp + 1)
{
printf (" % d is a prime number",n);
}
getch();
}
# include<conio.h>
void main()
{
int n, i, temp;
clrscr();
printf ( "Enter any number \n");
scanf("%d ,& n );
temp= n/2;
for ( i=2;i<= temp;i++)
}
if ( n % i= = 0)
{
printf("% d is not a prime no.",n);
break;
}
}
if (i = = temp + 1)
{
printf (" % d is a prime number",n);
}
getch();
}
2. How to print name 10 times in C language
#include<stdio.h>
#include<conio.h>
void main()
#include<conio.h>
void main()
{
int i;
char name[20];
clrscr();
printf("Enter your name");
gets(name);
for(i=1;i<=10;i++)
{
puts(name);
}
getch();
}
How to write a program in C language.
.
How to apply a loop in C language.
Comments
Post a Comment
DON'T COMMENT LINK.