1234554321
1234 4321
123 321
12 21
1 1
12 21
123 321
1234 4321
1234554321
Answer Posted / c++ coder
#include <iostream>
using namespace std;
int main()
{
int MAX =5; /*the number to which series needs to
be created*/
int i,j,k;
/* this loop will print first half of the series*/
for (int m = MAX; m >0 ; m-- )
{
cout<<endl;
for( i =0; i<m; i++) /*loop to print start
numbers from 1 to MAX in each line*/
cout<<(i+1);
for( k = 0; k< 2*(MAX-i);k++) /*space which
needs to be printed after the incremented num*/
cout<<" ";
for( j = i ; j>0 ; j--)/* loop to print
decremented num*/
cout<<j;
}
/* this loop will print next half of the series -
duplicate line skipped*/
for ( int n = 2; n <= MAX ; n++ )
{
cout<<endl;
for ( i = 0; i<n ; i++)
cout<<(i+1);
for( k = 0; k< 2*(MAX-i);k++)
cout<<" ";
for( j = i ; j>0 ; j--)
cout<<j;
}
cout<<endl;
}
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
Can we create object of abstract class?
Which is not an object oriented programming language?
Why polymorphism is used in oops?
Hi friends I have experience of 6 months in website design and maintanence. Now i am looking for other IT jobs.. to switch platform. please post any interview you know in chennai.
any one please tell me the purpose of operator overloading
This program numbers the lines found in a text file. Write a program that reads text from a file and outputs each line preceded by a line number. Print the line number right-adjusted in a field of 3 spaces. Follow the line number with a colon, then one space, then the text of the line. You should get a character at a time and write code to ignore leading blanks on each line. You may assume that the lines are short enough to fit within a line on the screen. Otherwise, allow default printer or screen output behavior if the line is too long (i.e., wrap or truncate). A somewhat harder version determines the number of spaces needed in the field for the line numbers by counting lines before processing the lines of the file. This version of the program should insert a new line after the last complete word that will fit within a 72-character line.
String = "C++ is an object oriented programming language.An imp feature of oops is classes and objects".Write a pgm to count the repeated words from this scenario?
What is encapsulation in simple terms?
What is abstraction in oop with example?
What language is oop?
How do you explain polymorphism?
What are the important components of cohesion?
Explain virtual inheritance?
What is ambiguity in inheritance?
Are polymorphisms mutations?