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


Please Help Members By Posting Answers For Below Questions

Do array subscripts always start with zero?

786


How can I sort more data than will fit in memory?

630


What is the description for syntax errors?

616


Can you please explain the difference between exit() and _exit() function?

595


program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)

1629






Explain what is a program flowchart and explain how does it help in writing a program?

650


What are disadvantages of C language.

650


Is fortran faster than c?

585


Explain how can a program be made to print the name of a source file where an error occurs?

692


Explain how can type-insensitive macros be created?

572


What is the difference between variable declaration and variable definition in c?

565


Why do we use null pointer?

608


What is the difference between a string and an array?

709


Can the size of an array be declared at runtime?

611


What is c standard library?

693