Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

This is novice programmer seeking help???

sravansai
Beginner
514 Views
#include
#include
unsigned int chec=0,lim=0;
char output[20];
FILE *fp;
int power(int a,int b)
{
int n,c=1;
for(n=0;n {
c*=a;
}
return c;
}
int check(unsigned int d,int a,int c)
{
fp=fopen(output,"a");
int y=0,x=0,n;
for(x=1;x<=c;x++)
{
for(y=2;y<=lim;y++)
{
n=power(x,y);
if(d==n)
{
fprintf(fp,"sum(%d:%d)=%d=%d**%d\\n",a,c,d,x,y);
}
}
}
}

int main()
{

unsigned int count=0,MAX,MIN;
scanf("%d%d%d",&MIN,&MAX,&lim);
unsigned int a[MAX],i,m=0,b[MAX],k=0,j=0,c,f;
for(i=1;i<=2;i++)
gets(output);

for(i=MIN;i<=MAX;i++)
{
a=i;
m++;
}
j=m;
for(m=0;m<=j-1;m++)
{
if(a>0)
{
for(i=2;i<=a-1;i++)
if(a%i==0)
break;
if(i==a)
{
b=a;
k++;
}
else
continue;
}
else
continue;
}
b[k++]='\\0';
for(k=0;b!='\\0';k++)
{
b;
}
/*printf("\\nThe Number of Prime numbers in the given range are.......%d",k);*/
fp=fopen(output,"w");
for(i=0;i<=k;i++)
{
c=b;
for(j=i+1;j {
c+=b;
m=check(c,b,b);

}
}
getch();
}




Sir this is what the program i wrote and am in a need of ur help that how to give command line arguments and how to use them....i'm just a school student....so please consider this and reply me as soon as possible.
And please give some remarks on the program that is shown above.
0 Kudos
1 Reply
Aubrey_W_
New Contributor I
514 Views

Hello,

To use command line arguments, you'll need to use the version of main() that takes two arguments. You can find an explanation at http://publications.gbdirect.co.uk/c_book/chapter10/arguments_to_main.html

I hope that helps.

Best regards,

==
Aubrey W.
Intel Software Network Support

0 Kudos
Reply