1 1
12 21
123 321
12344231 how i creat it with for loop??
Answer Posted / raju kalyadapu
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,k;
for(i=1;i<=4;i++) //Outer Loop
{
for(j=1;j<=4;j++) //Inner loop for left side pattern
{
if(j<=i) //condition for checking printing space or number
printf("%d",j);
else
printf(" ");
}
for(j=4;j>=1;j--) //Inner loop for right side pattern
{
if(j<=i) //condition for checking printing space or number
{
printf("%d",j);
}
else
printf(" ");
}
printf("
");
}
getch();
return 0;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is signed and unsigned?
What does the message "automatic aggregate intialization is an ansi feature" mean?
what is recursion in C
When should volatile modifier be used?
Explain the priority queues?
Explain what does it mean when a pointer is used in an if statement?
What is cohesion and coupling in c?
What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
What are the types of type qualifiers in c?
Dont ansi function prototypes render lint obsolete?
What are the 5 types of organizational structures?
What is the size of structure in c?
C program to find all possible outcomes of a dice?
How can I split up a string into whitespace-separated fields?
How to get string length of given string in c?