1
1 2
1 2 3
1 2 3 4
1 2 3
1 2
1
generate this output using for loop
Answer Posted / narasimharao
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,n;
printf("Enter n value:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(k=i;k<n;k++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("%d",j);
for(k=i;k<i+1;k++)
{
printf(" ");
}
}
printf("\n");
}
for(i=n-1;i>=1;i--)
{
for(k=i;k<n;k++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("%d",j);
for(k=i;k<i+1;k++)
{
printf(" ");
}
}
printf("\n");
}
getch();
}
| Is This Answer Correct ? | 1 Yes | 2 No |
Post New Answer View All Answers
if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0
Differentiate between a structure and a union.
write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?
What is the difference between formatted&unformatted i/o functions?
Is void a keyword in c?
What is ctrl c called?
What is difference between union and structure in c?
given post order,in order construct the corresponding binary tree
How many levels of pointers have?
the question is that what you have been doing all these periods (one year gap)
What is pragma in c?
Explain About fork()?
Is c easier than java?
Explain is it better to bitshift a value than to multiply by 2?
.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }