write a c++ program to display the following pattern:
a
a b
a b c

Okay. What do you have so far? Do you know how to use for loops? Do you know how to use a char vareiable?

ok here is the program :)

Imports System.IO

Public Class Form1

    Private pf As New Font("Arial", 10)     'this font will be used for the print
    Private sr As StreamReader

    Private Sub btnPrint_Click(sender As System.Object, e As System.EventArgs) Handles btnPrint.Click

        Try
            sr = New StreamReader("D:\My Documents\History of the Amiga.txt")
            Try
                pd.Print()
            Finally
                sr.Close()
            End Try
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

    End Sub

    'The PrintPage event is raised for each page to be printed. This Sub will handle
    'word wrap. It does this by parsing each line into blank delimited tokens and   
    'calculating the pront position of each token. If the current token will not fit
    'on the current line then a new line is started. Note that this sub will not    
    'handle a line with no blanks that is wider than the page printable width.      

    Private Sub pd_PrintPage_1(sender As System.Object, e As System.Drawing.Printing.PrintPageEventArgs) Handles pd.PrintPage

        Dim linesPerPage As Integer     'number of lines that will fit on a page    
        Dim yPos As Single = 0          'y position of the next line to print       
        Dim lineNum As Integer = 0      'the current line number                    
        Dim line As String = Nothing    'next line from text file                   

        'these must be declared as Static to preserve their values between calls    

        Static xPos As Single = 0       'x position of the next token to print      
        Static tokens() As String       'current line tokenized by blanks           
        Static tokidx As Single = -1    'index of next token to print               

        ' Calculate the number of lines per page.

        linesPerPage = e.MarginBounds.Height / pf.GetHeight(e.Graphics)

        ' Print each line of the file. 

        While lineNum < linesPerPage

            'if we are not continuing with unused tokens from the previous line     
            'then read a new line and parse it                                      

            If tokidx = -1 Then
                line = sr.ReadLine()                    'read a new line            
                If line Is Nothing Then Exit While
                xPos = e.MarginBounds.Left              'reset to left margin       
                tokens = line.Split()                   'parse the new line         
                tokidx = 0                              'reset token index          
            End If

            yPos = e.MarginBounds.Top + lineNum * pf.GetHeight(e.Graphics)

            'print all tokens

            While tokidx < tokens.Length

                'get the next token and calculate the required width

                Dim token As String = tokens(tokidx) & " "
                Dim w As SizeF = e.Graphics.MeasureString(token, pf)

                'if the token will fit on the current line then render it otherwise 
                'reset xpos to the left margin and start a new line                 

                If w.Width + xPos <= e.MarginBounds.Right Then
                    e.Graphics.DrawString(token, pf, Brushes.Black, New Point(xPos, yPos))
                    xPos += w.Width
                    tokidx += 1
                Else
                    xPos = e.MarginBounds.Left
                    Exit While
                End If

            End While

            'if all tokens have been processed then reset the index to -1 to force  
            'a read of a new line                                                   

            If tokidx = tokens.Length Then tokidx = -1
            lineNum += 1

        End While

        ' If more lines exist, print another page.

        e.HasMorePages = (line IsNot Nothing)

    End Sub

End Class
commented: Did you have a point to make here? -1
commented: Not even remotely related to this matter... +0

lol are you guys serious,
This is not Homework solve my problem, or please do my lazy work for me site.

the proplem is not even clear,
if you wanna see what this app might look like I just spent a useless 10 minutes at most wasting my time to show something simillar to what is needed here,

here is the code and the result next to follow and please if you post a negative flag try to fix it up please:

#include <iostream>
#include <string>

using namespace std;

int main()
{
    for (char c = 'a'; c<='z'; c++) {
        for (char x = 'a'; x<=c; x++) {
            cout << x << " ";
        }
        cout << endl;
    }

    system("pause");
    return 0;
}

the result is as this follow:
**
a
a b
a b c
a b c d
a b c d e
a b c d e f
a b c d e f g
a b c d e f g h
a b c d e f g h i
a b c d e f g h i j
a b c d e f g h i j k
a b c d e f g h i j k l
a b c d e f g h i j k l m
a b c d e f g h i j k l m n
a b c d e f g h i j k l m n o
a b c d e f g h i j k l m n o p
a b c d e f g h i j k l m n o p q
a b c d e f g h i j k l m n o p q r
a b c d e f g h i j k l m n o p q r s
a b c d e f g h i j k l m n o p q r s t
a b c d e f g h i j k l m n o p q r s t u
a b c d e f g h i j k l m n o p q r s t u v
a b c d e f g h i j k l m n o p q r s t u v w
a b c d e f g h i j k l m n o p q r s t u v w x
a b c d e f g h i j k l m n o p q r s t u v w x y
a b c d e f g h i j k l m n o p q r s t u v w x y z
**

commented: Spoon feeding! Not cool. -1
commented: lol, are you serious?! system("pause")? -3

So before you even find out if this is homework or not you just decide to do the assignment for them? What is that going to teach them?

As a question on your code why are you using system("pause")? Wouldnt cin.get() work just as well and be portable and safe?

hey tell me "system()" is in which header file? I mean to say which header file I have to include for using "system()".

hey tell me "system()" is in which header file?

#include <cstdlib>

THIS WORKS FOR TURBO C++::::::

        #include<iostream.h>
        #include<conio.h>
        void main()
        {   clrscr();
            char m;
            int n;
            cout<<"Enter the number of rows=";
            cin>>n;
            for(int i=1;i<=n;i++)
               {  cout<<"\n";
                  for(int j=1;j<=i;j++)
                 {  m=j+64;
                    cout<<m;
                 }
               }
            getch();
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.