Monday 27 August 2012

Array004

Input five numbers in an array. If these are even numbers then one will be store in the array or if these are odd numbers then zero will be store in the array.

#include <stdio.h>
#include <conio.h>

void main ( )
{
          int         n[5], n1[5], i;
          clrscr ( );
                                      
          for ( i = 0; i < 5; i++ )
          {                                        
                          printf ("\n\t\t\t Enter a number......:"); scanf ("%d", & n[i]);
                                                     
                          if ( n[i] % 2 == 0 )
                                            n1[i] = 1;
                          else                           
                                            n1[i] = 0;
          }                                                  
          printf ("\n\n");
          for ( i = 0; i < 5; i++ )
          {                                            
                          printf ("\n\t\t\t\t %d \t %d", n[i], n1[i]);
          }
          getch ( );
}
Click here to contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...