===========================================================================
CODING
#include<all.h>
void main()
{
int i,p,m,l,q,z,sum,a,b,d,h;
char c='c';
label:
clrscr();
i=0;
p=0;
m=0;
l=0;
q=0;
z=0;
sum=0;
a=0;
b=0;
d=0;
for(i=1;i<=100;i++)
{
if(c=='p')
{
m=i;
l=i;
for(q=0,p=0;l!=0;q++)
{
l=l/10;
p=p+1;
}
for(z=0,sum=0,a=0;m!=0;z++,p=p-1)
{
a=m%10;
m=m/10;
sum=a*pow(10,p-1)+sum;
}
if(sum==i)
textcolor(GREEN+BLINK);
else
textcolor(BLACK);
cprintf("%d ",i);
}
else if(c=='P')
{
for(z=2,sum=0;z<=sqrt(i);z++)
{
if(i%z==0)
sum=sum+i;
else
sum=sum+0;
}
if(sum==0)
textcolor(GREEN+BLINK);
else
textcolor(BLACK);
if(i==1)
textcolor(BLACK);
else;
cprintf("%d ",i);
}
else if(c=='F')
{
for(a=1,b=1;1==1;)
{
d=a+b;
a=b;
b=d;
if(d==i)
{
textcolor(GREEN+BLINK);
break;
}
else if(d>i)
{
textcolor(BLACK);
break;
}
else;
}
if(i==1)
textcolor(GREEN+BLINK);
else;
cprintf("%d ",i);
}
else if(c=='A')
{
m=i;
for(z=1,b=0,a=0;m!=0;z++)
{
a=m%10;
m=m/10;
b=a*a*a+b;
}
if(b==i)
textcolor(GREEN+BLINK);
else
textcolor(BLACK);
cprintf("%d ",i);
}
else if(c=='c')
{
textcolor(RED);
cprintf("%d ",i);
}
}
textcolor(WHITE);
cout<<"\n Chose the option:-";
cout<<"\n 1.)Pallindrome";
cout<<"\n 2.)Prime no.";
cout<<"\n 3.)Fibbonaci series";
cout<<"\n 4.)Armstrong";
cout<<"\n 5.)Couting from 1-100";
cout<<"\n Enter Option: ";
cin>>h;
switch(h)
{
case 1:c='p';goto label;break;
case 2:c='P';goto label;break;
case 3:c='F';goto label;break;
case 4:c='A';goto label;break;
case 5:c='c';goto label;break;
default:cout<<"\nWrong Input";
getch();
break;
}
getch();
}
CODING
#include<all.h>
void main()
{
int i,p,m,l,q,z,sum,a,b,d,h;
char c='c';
label:
clrscr();
i=0;
p=0;
m=0;
l=0;
q=0;
z=0;
sum=0;
a=0;
b=0;
d=0;
for(i=1;i<=100;i++)
{
if(c=='p')
{
m=i;
l=i;
for(q=0,p=0;l!=0;q++)
{
l=l/10;
p=p+1;
}
for(z=0,sum=0,a=0;m!=0;z++,p=p-1)
{
a=m%10;
m=m/10;
sum=a*pow(10,p-1)+sum;
}
if(sum==i)
textcolor(GREEN+BLINK);
else
textcolor(BLACK);
cprintf("%d ",i);
}
else if(c=='P')
{
for(z=2,sum=0;z<=sqrt(i);z++)
{
if(i%z==0)
sum=sum+i;
else
sum=sum+0;
}
if(sum==0)
textcolor(GREEN+BLINK);
else
textcolor(BLACK);
if(i==1)
textcolor(BLACK);
else;
cprintf("%d ",i);
}
else if(c=='F')
{
for(a=1,b=1;1==1;)
{
d=a+b;
a=b;
b=d;
if(d==i)
{
textcolor(GREEN+BLINK);
break;
}
else if(d>i)
{
textcolor(BLACK);
break;
}
else;
}
if(i==1)
textcolor(GREEN+BLINK);
else;
cprintf("%d ",i);
}
else if(c=='A')
{
m=i;
for(z=1,b=0,a=0;m!=0;z++)
{
a=m%10;
m=m/10;
b=a*a*a+b;
}
if(b==i)
textcolor(GREEN+BLINK);
else
textcolor(BLACK);
cprintf("%d ",i);
}
else if(c=='c')
{
textcolor(RED);
cprintf("%d ",i);
}
}
textcolor(WHITE);
cout<<"\n Chose the option:-";
cout<<"\n 1.)Pallindrome";
cout<<"\n 2.)Prime no.";
cout<<"\n 3.)Fibbonaci series";
cout<<"\n 4.)Armstrong";
cout<<"\n 5.)Couting from 1-100";
cout<<"\n Enter Option: ";
cin>>h;
switch(h)
{
case 1:c='p';goto label;break;
case 2:c='P';goto label;break;
case 3:c='F';goto label;break;
case 4:c='A';goto label;break;
case 5:c='c';goto label;break;
default:cout<<"\nWrong Input";
getch();
break;
}
getch();
}
===========================================================================
No comments:
Post a Comment