In: Computer Science
If none of the above conditions are met, simply print a blank new line
#include<stdio.h>
#include<math.h>
int prime(int x)
{
if(x<2)return 0;
if(x==2)return 1;
for(int i=2;i<=sqrt(x);i++)
{if(x%i==0)return 0;
}
return 1;
}
int main()
{int b=-1;
while(1)
{
int a;
printf("enter number ");//enter -1
for break
scanf("%d",&a);
if(a==-1)break;
if(prime(a))
{
printf("\033[1;31m");//convert next
written statment as red
printf("%d\n",a);
printf("\033[0m");//reset
}
else
if(a%7==0&&(a/7)%2==0)
{
printf("\033[1;32m");//convert next
written statment as green
printf("%d\n",a);
printf("\033[0m");//reset
}
else
if(b!=-1&&a%b==0&&(a/b)%2==0)
{
printf("\033[1;34m");//convert next
written statment as blue
printf("%d\n",a);
printf("\033[0m");//reset
}
else if(a%10==3)
{printf("\033[4m");//convert next
written statment as underlined
printf("%d\n",a);
printf("\033[0m");//reset
}
else
printf("\n");
b=a;
}
}
input ;- this is coloured check on your terminal
enter number 2
2
enter number 14
14
enter number 28
28
enter number 7
7
enter number 5
5
enter number 10
10
enter number 33
33
enter number
1
enter number