Saturday, November 13, 2010

Program to check whether number is prime or not in java

Write a Java program to find whether the given number is prime or not.





import java.io.*;
class prime{
  public static void main(String[] args)
 {
    int num,i;
try{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter number:");
num=Integer.parseInt(br.readLine());
  
     for (i=2; i < num ;i++ )
{
       int n = num%i;
     if (n==0)
{
         System.out.println("not Prime!");
         break;
     }
     }
     if(i == num)
{
       System.out.println("Prime number!");
     }
}catch(IOException e){}
  }
}


*+*+*+*+*+*+*+*OUTPUT+*+*+*+*+*+*+*+*+*+


Enter number:
19
Prime number!


*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+

Monday, November 8, 2010

MID SEM EXAM SYLLABUS OF IAP

Two assignment given by Reena ma`am and mid sem exam question by RJP sir.
also prepare Delegate and event programs from file.

MID SEM EXAM SYLLABUS IN JAVA

In Java programming all assignment given in Java section. 

MID SEM EXAM SYLLABUS OF MICROPROCESSOR

In microprocessor and peripheral chips all post posted below .

MID SEM EXAMS SYLLABUS IN COMPUTER NETWORKS

In mid semester exam syllabus of computer network is 1 to 5 practical of RJP sir and question given by MJP ma`am 

Command Line argument + IndexOf() program


Write a program that take a string and a character to be searched from command line input in the string 
and count the occurrence of that character in string and also display the appropriate message.




 //file name is cmd.cs
/* pass string without space in command line argument
*/

using System;
public class cmd{
public static void Main(string []args)
{
string str=args[0];
string s=args[1];
int ind=str.IndexOf(s);
Console.WriteLine("occurrence of {0} in {1} is : {2} ",s,str,ind);
}
}


_________________________________
*+*+*+*+*+*+OUTPUT*+*+*+*+*+*+*+


csc cmd.cs
cmd i_just_want_say_hi h
occurrence of h in i_just_want_say_hi is : 16
__________________________________
*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*

ORATOR OVERLOADING IN C#


Write a program to add two complex number by overloading + operator.

using System;
public class Complex
{
    public int real;
    public int imaginary;

    public Complex(int real, int imaginary)
    {
        this.real = real;
        this.imaginary = imaginary;
    }

    public static Complex operator +(Complex c1, Complex c2)
    {
        return new Complex(c1.real + c2.real, c1.imaginary + c2.imaginary);
    }

public void show()
{
Console.WriteLine("{0} + {1}i", this.real, this.imaginary);
}
}

class overloadplus
{
    static void Main()
    {
        Complex num1 = new Complex(12, 8);
        Complex num2 = new Complex(21, 4);
        Complex sum = num1 + num2;

        Console.WriteLine("First complex number:");
        num1.show();
        Console.WriteLine("Second complex number:") ;
        num2.show();
        Console.WriteLine("The sum of the two numbers:");
        sum.show();
    }
}



+++++++++++++++OUTPUT+++++++++++++++++++++
First complex number:                                
12 + 8i
Second complex number:
21 + 4i
The sum of the two numbers:
33 + 12i
************************************************

Tuesday, November 2, 2010

IAP Question(mid sem exams by RJP sir)


  1.  Explain the compilation process of program in .net.
  2.  Differentiate for loop and for each loop of c# with suitable example.
  3.  Explain component of .net with suitable diagram.
  4.  What is enumeration ? Explain with example.
  5.  Explain with example the types of inheritance .
  6.  What is delegate ? compare delegate of .net with call back method of c,c++ and also write to step to create and use delegate.
  7.  Differentiate structure and class with suitable example.
  8.  Explain at least six methods of string class with suitable example.     
  9. True and False:
    1. Logical operator have same level of precedence.
    2. Multi line comment start with /* ---- */.
    3. in C# program we can include multiple main method.
    4. Boxing allow to convert the value type to reference type then again to value type .
    5. Bitwise unary and comperation  overloaded in pack.
    6. Unmanaged code do not run under the control of  CLR.
    7. An assembly is a logical unit that contain non compile code.
  10. Write a program to add two complex number by overloading + operator.(SOLUTION)
  11. Write a program that take a string and a character to be searched from command line input in the string and count the occerance of that character in string and also display the appropriate message. (SOLUTION)