1
1 2
1 2 3
1 2 3 4
1 2 3
1 2
1
generate this output using for loop
Answers were Sorted based on User's Feedback
Answer / varsha shukla
#include<conio.h>
#include<stdio.h>
void main()
{
int i,j,k,l;
for(i=1;i<=4;i++)
{
for(k=i;k<=4;k++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf(" %d",j);
}
printf("\n");
}
for(i=3;i>0;i--)
{
for(l=i;l<=3;l++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf(" %d",j);
}
printf("\n");
}
getch();
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / 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 |
what is a stack
what is the output of below code int x=8,y; x>>=2; y=x; what is y value. NOTE:EXPLANATION IS COMPALSARY with binary bits
Once I have used freopen, how can I get the original stdout (or stdin) back?
What is the difference between constant pointer and pointer to a constant. Give examples.
What is the output for the below program? void main() { float me=1.1; double you=1.1; if(me==you) printf("love c"); else printf("know c"); }
main() { int a; a=++100; printf("%d",a); getch(); }
what is the maximum no. of bytes calloc can allocate
Tell me is null always defined as 0(zero)?
Hi, main() { } Is a user defined function or Built in Functionn
How can I dynamically allocate arrays?
Explain a file operation in C with an example.
IS Doon college of Engn.. has good faculty