Posts

INSERT AN ELMENT IN AN ARRAY AT DESIRED POSITION USING C PROGRAM

#include <stdio.h> int main (){ int a[50],size,num,i,pos,temp; printf( "\nEnter size of the array: " ); scanf( "%d" ,&size); printf( "\nEnter %d elements in to the array: " ,size); for (i=0;iscanf( "%d" ,&a[i]); printf( "\nEnter position and number to insert: " ); scanf( "%d %d" ,&pos,&num); i=0; while (i!=pos-1) i++; temp=size++; while (i{ a[temp]=a[temp-1]; temp--; } a[i]=num; for (i=0;iprintf( " %d" ,a[i]); return 0; }

DELETE ELEMENT FROM AN ARRAY AT DESIRED POSITION USING C

#include <stdio.h> void main () {   int a[50],i,pos,size;   clrscr();   printf( "\nEnter size of the array: " );   scanf( "%d" ,&size);   printf( "\nEnter %d elements in to the array: " ,size);   for (i=0;i<size;i++)             scanf( "%d" ,&a[i]);   printf( "\nEnter position where to delete: " );   scanf( "%d" ,&pos);   i=0;   while (i!=pos-1)             i++;   while (i<size)   {             a[i]=a[i+1];             i++;   }   size--;   for (i=0;i<size;i++)             printf( " %d" ,a[i]);   getch(); }

FIND OUT LARGEST NUMBER IN AN ARRAY USING C PROGRAM

#include <stdio.h> int main (){   int a[50],size,i,big;   printf( "\nEnter the size of the array: " );   scanf( "%d" ,&size);   printf( "\nEnter %d elements in to the array: ”, size);   for (i=0;i<size;i++)       scanf( "%d" ,&a[i]);   big=a[0];   for (i=1;i<size;i++){       if (big<a[i])            big=a[i];   }   printf( "\nBiggest: %d" ,big);   return 0; }

C Program to Get the Current System Date

#include <dos.h> #include <stdio.h> int main(void) { struct date d; getdate(&d); printf(“The current year is: %d\n”, d.da_year); printf(“The current day is: %d\n”, d.da_day); printf(“The current month is: %d\n”, d.da_mon); return 0; }

C Program to Get the Current System Time

#include <stdio.h> #include <dos.h> int main(void) { struct time t; gettime(&t); printf(“The current time is: %2d:%02d:%02d\n”, t.ti_hour, t.ti_min, t.ti_sec); return 0; }

Java program to display Local machines IP Address

import java.net.*; import java.io.*; public class iplocalmac {     public static void main(String args[]) throws Exception     {         InetAddress ipadd =InetAddress.getLocalHost();         System.out.println("Host and Address :"+ipadd);         System.out.println("Host name :"+ipadd.getHostName());         String n=ipadd.toString();         System.out.println("IP address :"+n.substring(n.indexOf("/")+1));     } }

Java program to display the IP Address of a particular Host

import java.net.*; import java.io.*; public class iphost {     public static void main(String args[]) throws Exception     {         System.out.println("Enter the host name :");         String n=new DataInputStream(System.in).readLine();         InetAddress ipadd =InetAddress.getByName(n);         System.out.println("IP address :"+ipadd);     } }