Advertisement
Guest User

Factors of a number

a guest
Aug 14th, 2015
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. /*
  2.  * File:   Aufgaben.c
  3.  * Author: reynaldogunawan
  4.  *
  5.  * Created on July 19, 2015, 6:29 PM
  6.  */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <assert.h>
  11. #include <math.h>
  12.  
  13. /*
  14.  *
  15.  */
  16. int main() {
  17.    
  18.     int number = 0;
  19.     int faktor[] = {};
  20.     int divider = 2;
  21.     int counter = 0;
  22.     int i = 0;
  23.    
  24.     printf("Type in a number: ");
  25.     scanf("%3d", &number);
  26.    
  27.     while(i <= number){
  28.         if(number % divider == 0){
  29.             faktor[i] = divider;
  30.             divider++;
  31.             counter++;
  32.         }
  33.         i++;
  34.     }
  35.     for(int j = 0; j <= counter; j++){
  36.         printf("%d%c ", faktor[j], j == counter ? '.' : ',');
  37.     }
  38.    
  39.     return (EXIT_SUCCESS);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement