#include <stdio.h>
#include <conio.h>
#include <math.h>
void secondfunction(int first,int last);
int main()
{
printf("we are going to solve an equation like a_{1}x^{n}+a_{2}x^{n-1}+...+a_{n}=0\n I hope you know LaTex");
printf("\n Please enter n:");
int n;
scanf("%d",&n);
int first=0,last=0;
for(int i=1;i<=n;i++)
{
printf("Please enter a_{%d}",i);
if(n==1)
{
scanf("%d",&first);
last=first;
}
else if(i==1)
{
scanf("%d",&first);
}//end of if
else if (i==n)
{
scanf("%d",&last);
}//end of else if
else
{
int u =0;
scanf("%d",&u);
}//end of else
}//end of for
// up to here we have all the input we need , now we're going to process it
int dfirst[32767];
int dlast[32767];
int num =0,numfirst=-1,numlast=-1;
for(num=1;num<=(float)first/2;num++)
{
if(first%num==0)
{
numfirst++;
dfirst[numfirst]=num;
}//end of if
}//end of for
for(num=1;num<=(float)last/2;num++)
{
if(last%num==0)
{
numlast++;
dlast[numlast]=num;
}//end of if
}//end of for
for(int i1 =0;i1<numfirst+1;i1++)
{
for (int i2=0;i2<numlast+1;i2++)
{
float answer = (float)dlast[i2]/dfirst[i1];
printf("One answer is: %f",answer);
{
}//end of if
}//end of for
}//end of for
getch();
return 1389;
}//end of main
[I][B][B][I]#include<iostream.h>
#include<conio.h>
main()
{
clrscr();
int i,l,j,k,n,a[100],an,a0,b=0,c=0,b1[100],c1[100],r=0;
double root,s;
cout<<"enter n:";
cin>>n;
for(i=n;i>=0;i--)
{
cout<<"enter a["<<i<<"]:";
cin>>a[i];
}
a0=abs(a[0]);
an=abs(a[n]);
for(i=1;i<=a0;i++)
if(a0%i==0)
{
b1[b]=i;
b1[b+1]=-i;
b+=2;
}
for(i=1;i<=an;i++)
if(an%i==0)
{
c1[c]=i;
c1[c+1]=-i;
c+=2;
}
for(i=0;i<b;i++)
for(j=0;j<c;j++)
{
s=0;
root=b1[i]/c1[j];
for(k=0;k<=n;k++)
{
for(l=0;l<k;l++)
s*=root;
s*=a[k];
}
if(s==0)
{
cout<<root<<endl;
r++;
}
}
if(r==0)
cout<<"This polynomial has no rational root!";
getch();
}
[I][B][B][I]#include<iostream.h>
#include<conio.h>
main()
{
clrscr();
int i,l,j,k,n,a[100],an,a0,b=0,c=0,b1[100],c1[100],r=0;
double root,s;
cout<<"enter n:";
cin>>n;
for(i=n;i>=0;i--)
{
cout<<"enter a["<<i<<"]:";
cin>>a[I];
}
a0=abs(a[0]);
an=abs(a[n]);
for(i=1;i<=a0;i++)
if(a0%i==0)
{
b1[B]=i;
b1[b+1]=-i;
b+=2;
}
for(i=1;i<=an;i++)
if(an%i==0)
{
c1[c]=i;
c1[c+1]=-i;
c+=2;
}
for(i=0;i<b;i++)
for(j=0;j<c;j++)
{
s=0;
root=b1[I]/c1[j];
for(k=0;k<=n;k++)
{
for(l=0;l<k;l++)
s*=root;
s*=a[k];
}
if(s==0)
{
cout<<root<<endl;
r++;
}
}
if(r==0)
cout<<"This polynomial has no rational root!";
getch();
}
x/y
(double)x/y
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
int armstrong(long unsigned int number)//checks if a number is armstrong
{
const int digit = 10;
register long unsigned int sum=0;
register long unsigned int copy = number;
while(copy!=0)
{
sum += (copy%digit)*(copy%digit)*(copy%digit);
copy = copy/10;
}
if(sum==number)
{
return 1;
}
else
{
return 0;
}
}//end of armstrong
int main()//main function
{
clrscr(); // clears the screen
printf("I'm going to find first n Armstrong numbers. Please enter n:");
register int n;
scanf("%d",&n);
int i =0;
register long unsigned int j=-1; // i is number of printed armstrong numbers,j is number to be checked
while(i<n)
{
j++;
if(armstrong(j))
{
i++;
cout<<j<<" is Armstrong"<<endl;
}
}
getch();
return 1389;
}//end of main