BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan

BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan (http://bzupages.com/)
-   Visual Programming (http://bzupages.com/237-visual-programming/)
-   -   Power Series (SIMPLE,EXTENDED) Visual Basic Console Application Code By Wasif (http://bzupages.com/f237/power-series-simple-extended-visual-basic-console-application-code-wasif-7197/)

.BZU. 15-12-2009 11:25 PM

Power Series (SIMPLE,EXTENDED) Visual Basic Console Application Code By Wasif
 
Power Series (SIMPLE)
Code:

Module Module1
 
      Sub Main()
 
 
 
          For n = 1 To 5
 
              If n = 5 Then
  Console.Write("{0}^{1} ", n, n + 1)
              Else
                  Console.Write("{0}^{1} + ", n, n + 1)
  End If
         
 
          Next
 
 
      End Sub
 
  End Module

Power Series (EXTENDED)
Output: 1^2 + 2^3+ 3^4 + … = 1+8+ 81 ….
Code:

  Module Module1
 
      Sub Main()
          Dim buffer As String
          Dim temp As Double
 
          temp = 0
          buffer = ""
          For n = 1 To 5
 
              If n = 5 Then
  temp = n ^ (n + 1)
                  Console.Write("{0}^{1} ", n, n + 1)
  buffer = buffer & temp
              Else
                  temp = n ^ (n + 1)
                  Console.Write("{0}^{1} + ", n, n + 1)
                  buffer = buffer & temp & "+"
              End If
 
 
          Next
 
          Console.WriteLine(" = " & buffer)
      End Sub
 
  End Module



All times are GMT +5. The time now is 04:13 PM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.