Results 1 to 3 of 3

Thread: Any wanna give explanation of this programs output?

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    1

    Any wanna give explanation of this programs output?

    #include <stdio.h>

    int main(){
    int a;
    int b = 4 ;
    int c;
    b*=b;

    for (a =1; a<b; ++a)
    {
    if(a%3 == 0 && a>3)
    {
    for (c=0; c< a-8 ;c++)
    {
    printf("%d\n", c);
    }
    }
    }
    system("pause");
    return (1);
    }

    The output is this

    0
    0
    1
    2
    3
    0
    1
    2
    3
    4
    5
    6

    regards!

  2. #2
    if(a%3 == 0 && a>3)

    I forgot what back 2 back equals signs was?

  3. #3
    Administrator Philip's Avatar
    Join Date
    May 1999
    Location
    Jacksonville, Florida, United States
    Posts
    8,250
    Blog Entries
    6
    Mad_Haggis, == is comparison operator, while single equal sign assigns value. i.e. a=3 would assign 3 to a, while a == 3 checks whether a equals 3. Then there are tripple comparison operators, like ===, !=== as well.

    This line actually means: if "a" is divisible by 3 (if when we divide it by 3 the remainder is zero), and if "a" is greater than 3 ...

Similar Threads

  1. Replies: 6
    Last Post: 03-12-05, 01:23 PM
  2. Wanna give a shot and see what's wrong with our connection?
    By M3wThr33 in forum General Broadband Forum
    Replies: 2
    Last Post: 09-11-04, 01:49 PM
  3. Would someone give me an explanation about American soldiers?
    By porkchop in forum General Discussion Board
    Replies: 19
    Last Post: 03-25-03, 07:58 PM
  4. anyone wanna give this a look?
    By Mgork in forum Broadband Tweaks Help
    Replies: 2
    Last Post: 01-31-02, 05:22 PM
  5. Replies: 2
    Last Post: 01-15-01, 12:55 AM

Bookmarks

Posting Permissions

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