C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » VB.NET Syntax »

Checking the perfect square of number


Posted Date: 30 Jul 2009    Resource Type: Code Snippets    Category: VB.NET Syntax
Author: NeetuMember Level: Diamond    
Rating: 1 out of 5Points: 10 (Rs 4)



It is console based application. Used to check whether the given number is perfect square or not.
see the attachements.



Dim no As Double
Dim no1 As Double
Dim s As String
Dim i As Integer

'To print the line
System.Console.WriteLine("Enter number")
'To read data from the user use System.Console.ReadLine and store in no
no = System.Console.ReadLine
'Math.Sqrt will calculate the square root of the number
no1 = Math.Sqrt(no)
'Math.Round(no1, 2) will return the number with 2 decimal places
no1 = Math.Round(no1, 2)
s = no1
'IndexOf(".") will return the position of decimal in number
i = (s.IndexOf("."))
'if it is less than or equal to zero then the given number is perfect Square else given number is not perfect square.
If i < 0 Then
System.Console.WriteLine("Square Root is " & no1)
System.Console.WriteLine(no & " is Perfect Square")
Else
System.Console.WriteLine("Square Root is " & no1)
System.Console.WriteLine(no & " is not the perfect Square")
End If


regards
Neetu

Attachments

  • Checking the perfect square of number (30900-30759-Assignment.rar)


  • Responses


    No responses found. Be the first to respond and make money from revenue sharing program.

    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Sign In to add tags.
    Check Perfect Square  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: Encrypt and Decrypt a String
    Previous Resource: Creating log files of error.
    Return to Discussion Resource Index
    Post New Resource
    Category: VB.NET Syntax


    Post resources and earn money!
     
    More Resources



    dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use