Results 1 to 6 of 6

Thread: Hystograph

  1. #1

    Thread Starter
    Fanatic Member Loraine's Avatar
    Join Date
    Aug 2006
    Location
    8ft. underground
    Posts
    581

    Hystograph

    Code:
    Dim ctr As Integer
    Dim i As String
    
    For ctr = 1 To 10
        If ctr Mod 2! = 0 Then
        Print ctr
        End If
    Next
    Well this is simple how to print an asterisk base on the answer of the if statement. the if statement will output all the even numbers base on the for loop
    Last edited by Loraine; Jul 21st, 2007 at 08:58 AM.

  2. #2

    Thread Starter
    Fanatic Member Loraine's Avatar
    Join Date
    Aug 2006
    Location
    8ft. underground
    Posts
    581

    Re: Hystograph

    When i use the "print ctr" in the if statement the output would be 2,4,6,8,10 but instead of those even numbers the output must be an astersik but base on the number of the even numbers liek [ 2 ** , 4 ****, 6 ******, 8 ******** ]

  3. #3
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Hystograph

    Hm, try this...

    Quote Originally Posted by Loraine
    Code:
    Dim ctr As Integer
    Dim i As String
    
    For ctr = 1 To 10
        If ctr Mod 2! = 0 Then
        Print ctr & " " & String(ctr, "*")
        End If
    Next
    Well this is simple how to print an asterisk base on the answer of the if statement. the if statement will output all the even numbers base on the for loop

  4. #4

    Thread Starter
    Fanatic Member Loraine's Avatar
    Join Date
    Aug 2006
    Location
    8ft. underground
    Posts
    581

    Re: Hystograph

    It's working but why did you use the
    Code:
    String(ctr, "*")
    But how if im not using the VB style im using the php how to output a asterisk base on the even numbers
    Code:
    $ctr = 0;
    
    for ($ctr = 1; $ctr < 10; $ctr++)
    {
                if ($ctr %2 !==1)
                {
                echo "$ctr" & "*";
                }
    }
    How about that ?

  5. #5
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Hystograph

    Quote Originally Posted by Loraine
    It's working but why did you use the
    Code:
    String(ctr, "*")
    But how if im not using the VB style im using the php how to output a asterisk base on the even numbers
    Code:
    $ctr = 0;
    
    for ($ctr = 1; $ctr < 10; $ctr++)
    {
                if ($ctr %2 !==1)
                {
                echo "$ctr" & "*";
                }
    }
    How about that ?
    That belongs in the PHP forum.

    I know some PHP but not aware if PHP has a buil in function like VB's String$() function.

    You could write your own:
    PHP Code:
    <?php
      
    function asterisk($length) {
        for(
    $i=1$i $length$i++) {
          
    $ret.= '*';
        }
        return 
    $ret;
      }
      
      for (
    $ctr 1$ctr 10$ctr++) {
        if (
    $ctr %!==1) {
          echo 
    "$ctr " asterick($ctr);
        }
      }
    ?>

  6. #6

    Thread Starter
    Fanatic Member Loraine's Avatar
    Join Date
    Aug 2006
    Location
    8ft. underground
    Posts
    581

    Re: Hystograph

    No without using a function just simple as the way you interpret in VB. How simply output the asterisk base on the even numbers. I use the phpjust a sample i can use also the C++. Just to know ohter way to output the asterisk

    Code:
    PHP:
    $ctr = 0;
    
    for ($ctr = 1; $ctr < 10; $ctr++)
    {
                if ($ctr %2 !==1)
                {
                echo "$ctr" & "*";
                }
    }
    
    C++:
    int ctr;
    
    for (ctr = 1; ctr < 10; ctr++)
    {
             if (ctr %2 !==1)
             {
             cout <<"*";
             }
    }
    i just want to know the other way

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width