Easy Tutorial
❮ C Examples Table Style C Exercise Example12 ❯

C Exercise Example 81

C Language Classic 100 Examples

Question: 809??=800??+9?? where ?? represents a two-digit number, 809?? is a four-digit number, 8?? results in a two-digit number, and 9?? results in a three-digit number. Find the two-digit number represented by ??, and the result of 809*??.

Program Analysis: None.

Example

//  Created by www.tutorialpro.org on 15/11/9.
//  Copyright © 2015 tutorialpro.org. All rights reserved.

#include <stdio.h>

void output(long int b, long int i){
    printf("\n%ld = 800 * %ld + 9 * %ld\n", b,i,i);
}

int main(){

    void output(long int b, long int i);
    long int a,b,i;
    a = 809;
    for(i = 10; i < 100; i++){
        b = i * a;
        if (b >= 1000 && b <= 10000 && 8 * i < 100 && 9 * i >= 100){
            output(b, i);
        }
    }
    return 0;
}

The above example outputs the following result when run:

9708 = 800 * 12 + 9 * 12

C Language Classic 100 Examples

❮ C Examples Table Style C Exercise Example12 ❯