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 difference between c &c++?
Is null valid for pointers to functions?
What is c variable?
Explain what are the __date__ and __time__ preprocessor commands?
What is sorting in c plus plus?
#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }
How to write c functions that modify head pointer of a linked list?
What is 1d array in c?
How many types of arrays are there in c?
what is the difference between 123 and 0123 in c?
If jack lies on Mon, Tue Wed and jill lies on Thursday, Friday and Saturday. If both together tell they lied yesterday. So c the given options and then c cos in the given dates one will be saying the truth and one will be lying. I got Thursday as option because jack is saying the truth he lied yest but jill is lying again as he lies on that day.
What are register variables? What are the advantage of using register variables?
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?
What functions are used in dynamic memory allocation in c?
Is it fine to write void main () or main () in c?