Write a program in c to print
1
121
12321
1234321
123454321
Answer Posted / rahim
int i, j, k, num = 5;
cout << "number u1=";
cin >> num;
for (i = 1; i <= num; i++)
{
for (j = 1; j <= num - i; j++)
{
cout << " ";
}
for (k = 1; k < i; k++)
{
cout << k;
}
for (k = i; k >= 1; k--)
{
cout << k;
}
cout << endl;
}
//----------------------------------------
for (i = num; i >= 1; i--)
{
for (j = 1; j <= num - i; j++)
{
cout << " ";
}
for (k = 1; k < i; k++)
{
cout << k;
}
for (k = i; k >= 1; k--)
{
cout << k;
}
cout << endl;
}
Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
What is the translation phases used in c language?
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
What is define c?
Can we assign string to char pointer?
To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
What does the file stdio.h contain?
What are the different types of data structures in c?
What is the easiest sorting method to use?
How many loops are there in c?
How can I find the modification date and time of a file?
Write a Program to find whether the given number or string is palindrome.
#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }
What is #include stdio h and #include conio h?
how to find binary of number?
What are types of structure?