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 are the parts of c program?
what is develop in c language
void main() { //char ch; unsigned char ch; clrscr(); for(ch =0;ch<= 127; ch++) printf(" %c= %d \t ", ch, ch); } output?
What is the best way to comment out a section of code that contains comments?
is c language is a object oreinted language?
is it possible to create your own header files?
how to capitalise first letter of each word in a given string?
Write a program to enter the name and age. If age>28 then find salary categories. if age<28 then find that you are gaduate or not.
i need all types of question paper releted to "c" and other language.
Reverse a string word by word??
How can I find leaf node with smallest level in a binary tree?
How to print %d in output