sumedh..... said:
int main()
{
int p=0;
int j,n;
printf("Enter n");
scanf("%d",&n);
j=n-1;
printf("\n\n");
printf("\t\t");
for(int p=0;p<2*n-1;p++)
{
for(int i=abs(j);i<n;i++)
printf("* ");
j--;
if(j>=0)
{
printf("\n\t\t");
int k=n-1-j;
while(k>0)
{printf("\b\b");k--;}
}
else
{
printf("\n\t\t");
int k=n-1-abs(j);
while(k>0)
{printf("\b\b");k--;}
}
}
}
happy programming..
lets discuss on complexity in this respect...
can anyone suggest how can the program be made more efficient..
...
Coding is not a big deal but efficiency is...
I'd make the exact reverse argument. Given the poor indentation,
structure, variable names, and lack of comments, it's very difficult to
figure out what your program is supposed to do.
In the "Real World"(tm), programs aren't written and forgotten. They're
maintained by people, often people who didn't originally write them.
The coding style and readability/maintainability/scalability are much
more important than the sort of micro-optimization that you are asking
about.
Have you benchmarked this code to see if there's a bottleneck? How do
you know it's not "efficient"? For that matter, please define "efficient".