Showing posts with label simple. Show all posts
Showing posts with label simple. Show all posts
on Sunday, 2 February 2014
import java.io.*;


import java.util.*;
/** * * @author Hira */publicclass Filespaths {

    /**     * @param args the command line arguments     */publicstaticvoid main(String[] args) {
        try {
        Path p=Paths.get("C:\\outfile\\outfile.txt");
        System.out.println(p);
        System.out.println(p.toAbsolutePath().toString());
        System.out.println(p.getParent());
        System.out.println(p.getRoot());
        System.out.println(Files.exists(p));
         System.out.println(p.getFileName());
         Files.deleteIfExists(p);
     
       
        } catch (IOException ex) {
            System.err.println(ex.getMessage());
        }
       
    List<Integer> e=Arrays.asList(2,3,5,6,7,8,0);
    List<Integer> f=Arrays.asList(12,13,14,15,16,12,18);
    System.out.println(e);
    System.out.println(f);
    try{
    for(int i=0;i<e.size();i++){
        int o=f.get(i)%e.get(i);
        System.out.println(o);  
    }
    }catch(ArithmeticException g){
        System.err.println("Exception caught :"+g.getMessage());
    }
    }
}
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
#include <process.h>

int main()
{
    char state = '0';
    char ch = NULL;
    char token[20]={NULL};
    char stt[3][2]= {NULL, '2',
             '0', '1',
             '1', '1'};
    cout<<"Input integer value : ";
    cin>>token;

    for(int i=0; token[i] != NULL; i++)
    {
        if(isdigit(token[i]))
        {
            ch='2';
        }
        else
        {
            printf("Invalide value");
            getchar();
            exit(0);
        }
        for(int j=1; j<3 && ch != stt[0][j]; j++);
        for(int k=1; k<2 && state != stt[k][0]; k++);
        state=stt[k][j];

    }
    printf("Valide value");  
    getchar();
    return 0;
}
on Monday, 20 January 2014
#include<iostream.h>
 #include<conio.h>

 int largest(int,int,int);

 main()
    {
       clrscr();


       int value_1;
       int value_2;
       int value_3;
       int maximum;

       cout<<"\n Enter the value_1 =  ";
       cin>>value_1;

       cout<<"\n Enter the value_2 =  ";
       cin>>value_2;

       cout<<"\n Enter the value_3 =  ";
       cin>>value_3;

       maximum=largest(value_1,value_2,value_3);

       cout<<"\n The largest integer is = "<<maximum<<endl;

       getch();
       return 0;
    }

 /*************************************************************************///-------------------------  largest(int,int,int)  ----------------------///*************************************************************************/int largest(int x,int y,int z)
    {
       int largest=x;

       if(y>largest)
      largest=y;

       if(z>largest)
      largest=z;

       return largest;
    }
#include<iostream.h>
#include<conio.h>
void kal(int *a,int *b)
{
    int *temp,i;
    temp=&i;
    *temp=*a;
    *a=*b;
    *b=*temp;
}

main()
{
    clrscr();
    int i=5,j=10;
    cout<<"Before swapping I = "<<i<<" J = "<<j<<endl;
    kal(&i,&j);
    cout<<"After swapping I = "<<i<<" J = "<<j<<endl;
}