Showing posts with label C - Array. Show all posts
Showing posts with label C - Array. Show all posts

Saturday, June 30, 2012

To Enter values in integer array

#include<stdio.h>
#include<conio.h>
int main(void)
{
   int num_array[10];
   int i;
   printf("\n\nINPUT\n\n");
   for(i=0; i<10; i++)
   {
      printf("Enter Element %d : ",i+1);
      scanf("%d",&num_array[i]);
   }
   printf("\n\nOUTPUT\n\n");

   for(i=0; i<10; i++)
   {
      printf("Element %d : %d",i+1,num_array[i]);
   }

   getch();
   return 0;
}

To Enter a string

#include<stdio.h>
#include<conio.h>
int main(void)
{
   char message[40];
   printf("Enter String : ");
   gets(message);
   printf("\n\n\nString is : ");
   puts(message);    
   getch();
   return 0;
}