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
find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
What is file in c language?
When should a type cast not be used?
What is difference between %d and %i in c?
What is the best organizational structure?
What is dynamic memory allocation?
Why array is used in c?
Can you write a programmer for FACTORIAL using recursion?
Where in memory are my variables stored?
Is there a way to compare two structure variables?
What does s c mean in text?
i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none
Is python a c language?
What are the characteristics of arrays in c?