Thread: Code Blocks showing error in code! Don't know what's it.

  1. #1
    Registered User
    Join Date
    Aug 2017
    Posts
    28

    Code Blocks showing error in code! Don't know what's it.

    Here is my code:

    Code:
    //Program showing factor of a number
    
    
    #include <stdio.h>
    #include <conio.h>
    #include <stdlib.h>
    
    
    int main()
    {
    system("cls");
    
    
    int num;
    
    
    printf("User enter the number to find factors of? ");
    scanf("%d", &num);
    
    
    for (int i = 1, i < num; ++i) {
        int counter = 1;
        if ( num%i == 0) {
            printf("%d Factor: %d \t", counter, i);
            counter++;
        }
    }
    
    
    }

    And here are my compiler's warnings and errors.

    ||=== Build: Release in eg01 (compiler: GNU GCC Compiler) ===|
    C:\Users\Dushyant\cProjects\eg01\main.c||In function 'main':|
    C:\Users\Dushyant\cProjects\eg01\main.c|16|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
    C:\Users\Dushyant\cProjects\eg01\main.c|16|error: expected ';' before ')' token|
    ||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,458
    It looks like you have a comma where it should be a semicolon in your for() loop.


    Jim

  3. #3
    Registered User
    Join Date
    Aug 2017
    Posts
    28
    Thanks jimblumberg, problem solved.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code::Blocks error multiple definition of 'main'
    By amber18 in forum C++ Programming
    Replies: 7
    Last Post: 07-05-2013, 02:13 PM
  2. Code::blocks 'undefined reference' error
    By Click_here in forum General Discussions
    Replies: 22
    Last Post: 04-27-2013, 07:15 PM
  3. Code blocks version? Error at the very start
    By Trejox in forum C++ Programming
    Replies: 4
    Last Post: 02-05-2013, 03:05 AM
  4. Code showing error
    By chaklader in forum C++ Programming
    Replies: 11
    Last Post: 01-25-2012, 06:58 AM
  5. Code showing error
    By chaklader in forum C++ Programming
    Replies: 5
    Last Post: 01-05-2012, 01:15 AM

Tags for this Thread