Advertisement
Draconk

parells, senars

Feb 19th, 2014
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     FILE *senars=NULL,*parells=NULL;
  7.     int n;
  8.  
  9.     if((senars=fopen("senars.txt","w"))==NULL){
  10.         printf("Error al abrir/crear el archivo\n");
  11.     }else if ((parells=fopen("parells.txt","w"))==NULL){
  12.         printf("Error al abrir/crear el archivo\n");
  13.     } else {
  14.         for (n=1; n<=100; n++){
  15.             if (n%2==0){
  16.                 fprintf(parells,"%d ", n);
  17.             }
  18.             else {
  19.                 fprintf(senars,"%d ",n);
  20.             }
  21.         }
  22.     }
  23.  
  24.  
  25.     system("pause");
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement