Hi im writing a program in C that will find the prime factors of a number. When i compile it and put in a number i dont get any thing Any idea what i did wrong in my code?

#include <stdio.h>

int main()
{

int n, k;

printf("Enter the number to factor:");
scanf("%d",&n);
printf("\nThe prime factors of %d are",n);
for(k=2; k*k<=n;)
{
if (n<0)
break;}

if( n%k==0)
{
printf(" %d",k);

n=n/k;
}
else
{
k++;

}

printf("n");

return(0);
}

I don't think you want to be printing "n" in the last prinf statement.
I think you want to print the number which is just the variable n.
Also please post your code using code tags so smiley faces dont show up in the middle of the code. ;)

EDIT
It also looks like there is somehing wrong with the for loop. Generally a for loop consists of three terms, with the last one being an increment or decrement.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.