Please fill in the missing lines of code to implement the logic given below.
Logic:
• - Accept a number x as input.
• if x is a prime number, print "prime"
• if x is not a prime number, then print "odd" if x is an odd number - if x is not a prime number, then print "even" if x is an even number
Ambiance
Answers
Answered by
0
Answer:
then all the numbers will be x """ the anser
Explanation:
of this q is
Answered by
2
Answer:
Hi guys this is the code done with c language, don’t get too puzzled with conditions ,you just have to focus on main “prime numbers” condition.
Explanation:
#include<stdio.h>
void main()
{
int x;
scanf("%d",&x);
int i,flag=0;
for(i=2;i<=x/2;++i)
{
if(x%i==0)
//by aaditya
{
flag=1;
break;
}
}
if(flag==0)
{
printf("prime");
}
else
{
if(flag==1 && x%2!=0)
{
printf("odd");
}
else
{
printf("even");
}
}
}
Similar questions
Computer Science,
5 months ago
Science,
5 months ago
Social Sciences,
10 months ago
Physics,
10 months ago
Math,
1 year ago