Write a program in c to print
1
121
12321
1234321
123454321
Answer Posted / sahil and dipanshu
#include<stdio.h>
#include<iostream.h>
int main()
{
int i,j,k,num;
num=5;
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-1;
}
cout<<endl;
}
return 0;
}
| Is This Answer Correct ? | 21 Yes | 8 No |
Post New Answer View All Answers
What is the modulus operator?
Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?
Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
What are control structures? What are the different types?
write a c program to calculate sum of digits till it reduces to a single digit using recursion
What is typedef example?
Simplify the program segment if X = B then C ← true else C ← false
how is the examination pattern?
What is union and structure in c?
What is p in text message?
What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.
What does void main return?
Can you define which header file to include at compile time?
Is c programming hard?
Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?