Thursday, December 5, 2019

Skill Enhancement Courses (SEC) python language

                                                      Question Set 1
  1.  What is high level language?
  2. Comparison of high level language and machine level language.
  3. What do you mean by compiler?
  4. Advantages and disadvantages of flowchart.
  5. Advantages and disadvantages of algorithm.
  6. Flowchart/algorithm-  i) odd/even checking ii) prime number checking iii) factorial of a number iv) Fibonacci series
  7. Data type- int, char, float.
  8. What do you mean by type casting?
  9. Example of logical operator and bitwise operator.
  10. Difference between while loop and do-while loop.
  11. Difference between while loop and for loop.
  12. Difference between break and continue.
  13. Difference between variable declaration and variable definition.
  14. Explain if and nested if.
  15. Explain loop and nested loop.
  16. WAP to display the first n terms of Fibonacci series.
  17. WAP to reverse a number.
  18. WAP to calculate the sum and product of digit of a number. CLICK
  19. WAP to display the factorial of a number. CLICK
  20. WAP to check a number is prime or not. CLICK
  21. WAP to check a number is perfect or not. CLICK
  22. WAP to check a number is strong or not. CLICK
  23. WAP to display the prime numbers in a range. CLICK
  24. WAP to display the first n perfect numbers.
  25. WAP to display the first n strong numbers.
  26. WAP to check a year is leap year or not. CLICK
  27. WAP to check a number is palindrome or not.
  28. List-  print(), append(), insert().
  29. List -  len(),max(),min().append(),insert().
  30. Searching in a list.
  31. Common elements in lists.

Skill Enhancement Courses (SEC) - c language


                                                       Question Set - 1
1. What is high level language?
2. Comparison of high level language and machine level language.
3. What do you mean by compiler?
4. Advantages and disadvantages of flowchart.
5. Advantages and disadvantages of algorithm.
6. Size of datatype- int,char,float.
7. Difference between prefix++ and postfix ++.
8. Example of logical operator and bitwise operator.
9. Difference between while loop and do-while loop.
10. Difference between while loop and for loop.
11. Difference between break and continue.
12. Difference between variable declaration and variable definition.
13. What do you mean by subscripted variable.
14. What do you mean by dynamic memory alloaction?
15. Write a c program to swap two values using 3rd variable.
16. Write a c program to swap two values without using 3rd variable.
17. Write a c program to find n!.
18. Write a c program to compute nCr, nPr.
19. Write a c program to largest and smallest number from a set of n numbers using array.
20. Write a c program to sort n numbers in ascending order.
21. Write a c program to sort n numbers in descending order.
22. Write a c program to perform addition,subtraction, multiplication of matrices.



Saturday, September 21, 2019

array insertion deletion using c++


                                                                                                   edited by:: Subhrajit Gorai
                                                                                                                      CMSA 1st sem


source code::



#include<iostream>
#include<conio.h>
using namespace std;

class Array{
                int arr[100],l,e,n;
                public:  
                                void input(){
                                cout<<"Enter the length of the array :";
                                cin>>l;  
                                cout<<"Enter the elements of the array :\n";
                                for(int i=0;i<l;i++)
                                cin>>arr[i];
                                }
                               
                                void output(){
                                cout<<"\nThe elements of the array :\n";
                                for(int i=0;i<l;i++)
                                                cout<<arr[i]<<" , ";
                }
                                               
                void insert_At_Begin(){
                                                cout<<"\nEnter the elements to be inserted in the array :\n";
                                                cin>>e;
                                                l++;
                                                for(int i=l-2;i>=0;i--){
                                                                arr[i+1]=arr[i];
                                                }
                                                arr[0]=e;
                                                output();
                                }
               
                void del_At_Begin(){
                                l--;
                                for(int i=0;i<l;i++)
                                                arr[i]=arr[i+1];
                                                output();
                                }
               
                void insert_At_End(){
                                cout<<"\nEnter the elements to be inserted in the array :\n";
                                cin>>e;
                                l++;
                                arr[l-1]=e;
                                output();
                }
               
                void del_At_End(){
                                                l--;
                                                output();
                }
               
                void insert_At_Index(){
                                                cout<<"Enter the position of the array where the element is to be inserted :";
                                                cin>>n;
                                                while(n>l||n<0){
                                                cout<<"\nINVALID POSITION entered........!!!!";
                                                cout<<"\nEnter the position of the array where the element is to be AGAIN :";
                                                cin>>n;
                                                }
                                                cout<<"\nEnter the elements to be inserted in the array :\n";
                                                cin>>e;
                                                l++;
                                                --n;
                                                for(int i=l-2;i>=n;i--){
                                                                arr[i+1]=arr[i];
                                                }
                                                arr[n]=e;
                                                output();
                                }
               
               
                void del_At_Index(){
                                cout<<"\nEnter the position of the array where the element is to be Deleted :";
                                cin>>n;
                                while(n>l||n<0){
                                                cout<<"\nINVALID POSITION entered........!!!!";
                                                cout<<"\nEnter the position of the array where the element is to be AGAIN :";
                                                cin>>n;
                                }
                                n=n-1;
                                                for(int i=n;i<l;i++)
                                                                arr[i]=arr[i+1];
                                l--;
                                output();
                }
               
                void cho(){
                                int c;
                                cout<<"\n\n  1. Insert Element at the Begining.\n  2. Insert Element at the End.\n  3. Insert Element at any desired position.\n  4. Delete Element at the Begining.\n  5. Delete Element at the End.\n  6. Delete Element at any desired position.\n  7. Exit\n";

                                cout<<"\nEnter the choice:";
                                                cin>>c;
                                                switch (c)
                                                {
                                                case 1:
                                                                insert_At_Begin();
                                                                 break; 
                                                case 2:
                                                                insert_At_End();
                                                                 break; 
                                                case 3:
                                                                insert_At_Index();
                                                                 break; 
                                                case 4:
                                                                del_At_Begin();
                                                                 break; 
                                                case 5: 
                                                                del_At_End();
                                                                   break;                               
                                                case 6:
                                                                del_At_Index();
                                                                 break; 
                                                case 7: exit(0);                  
                                                default :cout<<" Wrong Choice!!!!\n Enter the choice Again.... ";
                                                                                 cho();
                                                }
                }
};
                int main(){
                                int s=0;
                                Array ob;
                                ob.input();
                                ob.output();
                                for(int k=0;;k++)
                                ob.cho();
                                getch();
                                return 0;
}                                             





output::








Sunday, August 4, 2019

basic operator in vb6



Private Sub Form_Load()
Dim a, b, c, d, e, f As Integer
a = 5
b = 4
c = a + b

d = a - b

e = a * b

f = a / b

MsgBox ("sum=" & c & vbCrLf & "differnce=" & d & vbCrLf & "multiplication=" & e & vbCrLf & "division=" & f)


End Sub


output


Tuesday, May 7, 2019

synchronization




class PrintTable{ 
//synchronized method.
    public synchronized void printTable(int n){
       System.out.println("Table of " + n);
       for(int i=1;i<=10;i++){
           System.out.println(n*i);
           try{
        Thread.sleep(500);
           }catch(Exception e){
        System.out.println(e);
           }
        }     
    }
}

class MyThread1 extends Thread{
    PrintTable pt;
    MyThread1(PrintTable pt){
    this.pt=pt;
    }
    public void run(){
    pt.printTable(2);
    }     
}

class MyThread2 extends Thread{
PrintTable pt;
MyThread2(PrintTable pt){
this.pt=pt;
}
public void run(){
pt.printTable(5);
}
}

public class p1{
    public static void main(String args[]){
    //creating PrintTable object.
    PrintTable obj = new PrintTable();

    //creating threads.
    MyThread1 t1=new MyThread1(obj);
    MyThread2 t2=new MyThread2(obj);

    //start threads.
    t1.start();
    t2.start();
    }
}



C:\Users\Com science\Documents>java p1
Table of 2
2
4
6
8
10
12
14
16
18
20
Table of 5
5
10
15
20
25
30
35
40
45
50

C:\Users\Com science\Documents>

with out synchronization


class PrintTable{   
    public void printTable(int n){
      // synchronized(this){
       System.out.println("Table of " + n);
           for(int i=1;i<=10;i++){
               System.out.println(n*i); 
               try{ 
            Thread.sleep(500); 
               }catch(Exception e){
            System.out.println(e);
               } 
            }
       //}           
    } 


class MyThread1 extends Thread{ 
    PrintTable pt; 
    MyThread1(PrintTable pt){ 
    this.pt=pt; 
    } 
    public void run(){
    pt.printTable(2); 
    }       


class MyThread2 extends Thread{ 
PrintTable pt; 
MyThread2(PrintTable pt){ 
this.pt=pt; 

public void run(){ 
pt.printTable(5); 



public class p1{ 
    public static void main(String args[]){
    //creating PrintTable object.
    PrintTable obj = new PrintTable(); 

    //creating threads.
    MyThread1 t1=new MyThread1(obj); 
    MyThread2 t2=new MyThread2(obj); 

    //start threads.
    t1.start(); 
    t2.start(); 
    } 
}



C:\Users\Com science\Documents>java p1
Table of 5
5
Table of 2
2
4
10
6
15
20
8
10
25
12
30
35
14
16
40
45
18
50
20

C:\Users\Com science\Documents>

synchronization

class PrintTable{   
    public void printTable(int n){
       synchronized(this){
       System.out.println("Table of " + n);
           for(int i=1;i<=10;i++){
               System.out.println(n*i); 
               try{ 
            Thread.sleep(500); 
               }catch(Exception e){
            System.out.println(e);
               } 
            }
       }           
    } 


class MyThread1 extends Thread{ 
    PrintTable pt; 
    MyThread1(PrintTable pt){ 
    this.pt=pt; 
    } 
    public void run(){
    pt.printTable(2); 
    }       


class MyThread2 extends Thread{ 
PrintTable pt; 
MyThread2(PrintTable pt){ 
this.pt=pt; 

public void run(){ 
pt.printTable(5); 



public class p1{ 
    public static void main(String args[]){
    //creating PrintTable object.
    PrintTable obj = new PrintTable(); 

    //creating threads.
    MyThread1 t1=new MyThread1(obj); 
    MyThread2 t2=new MyThread2(obj); 

    //start threads.
    t1.start(); 
    t2.start(); 
    } 
}



C:\Users\Com science\Documents>java p1
Table of 2
2
4
6
8
10
12
14
16
18
20
Table of 5
5
10
15
20
25
30
35
40
45
50

C:\Users\Com science\Documents>

nested try



import java.util.*;
public class p1 {
    public static void main(String[] args) {
        try {
            System.out.println("Outer try block starts");
            try {
                System.out.println("Inner try block starts");
                int res = 5 / 0;
            } catch (InputMismatchException e) {
          System.out.println("InputMismatchException caught");
            } finally {
                System.out.println("Inner final");
            }
        } catch (ArithmeticException e) {
            System.out.println("ArithmeticException caught");
        } finally {
            System.out.println("Outer finally");
        }
    }
}






C:\Users\Com science\Documents>java p1
Outer try block starts
Inner try block starts
Inner final
ArithmeticException caught
Outer finally

C:\Users\Com science\Documents>

text box and command button

import java.awt.*;
import java.awt.event.*;
class p1 extends Frame implements ActionListener{
TextField tf;
p1(){

tf=new TextField();
tf.setBounds(60,50,170,20);
Button b=new Button("click me");
b.setBounds(100,120,80,30);


b.addActionListener(this);


add(b);add(tf);
setSize(300,300);
setLayout(null);
setVisible(true);
}
public void actionPerformed(ActionEvent e){
tf.setText("Welcome");
}
public static void main(String args[]){
new p1();
}
}







event handling

 1. text box & command button -- LINK
 2. BASIC INTRODUCTION LINK LINK2

3. keyboard  handling -- link
4. mouse handling -- link

Friday, May 3, 2019

keyboard handling

1.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="Key" width=300 height=400>
</applet>
*/
public class Key extends Applet
implements KeyListener
{
int X=20,Y=30;
String msg="KeyEvents--->";
public void init()
{
addKeyListener(this);
requestFocus();
setBackground(Color.green);
setForeground(Color.blue);
}
public void keyPressed(KeyEvent k)
{
showStatus("KeyDown");
int key=k.getKeyCode();
switch(key)
{
case KeyEvent.VK_UP:
showStatus("Move to Up");
break;
case KeyEvent.VK_DOWN:
showStatus("Move to Down");
break;
case KeyEvent.VK_LEFT:
showStatus("Move to Left");
break;
case KeyEvent.VK_RIGHT:
showStatus("Move to Right");
break;
}
repaint();
}
public void keyReleased(KeyEvent k)
{
showStatus("Key Up");
}
public void keyTyped(KeyEvent k)
{
msg+=k.getKeyChar();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,X,Y);
}
}


<applet code="Key" width=200 height=60>
</applet>







Example2:


import java.awt.*;

import java.applet.*;



public class Key1 extends Applet

{

    int keyPressed;



    public void init()

    {

        keyPressed = -1;



        Font font =  new Font("TimesRoman", Font.BOLD, 144);

        setFont(font);



        resize(200, 200);

    }



    public void paint(Graphics g)

    {

        String str = "";



        if (keyPressed != -1)

        {

            str += (char)keyPressed;

            g.drawString(str, 40, 150);

        }

    }



    public boolean keyDown(Event evt, int key)

    {

        keyPressed = key;

        repaint();

        return true;

    }

}

<applet code="Key1" width=200 height=60>
</applet>


mouse handling

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="Mouse" width=500 height=500>
</applet>
*/
public class Mouse extends Applet
implements MouseListener,MouseMotionListener
{
int X=0,Y=20;
String msg="MouseEvents";
public void init()
{
addMouseListener(this);
addMouseMotionListener(this);
setBackground(Color.black);
setForeground(Color.red);
}
public void mouseEntered(MouseEvent m)
{
setBackground(Color.magenta);
showStatus("Mouse Entered");
repaint();
}
public void mouseExited(MouseEvent m)
{
setBackground(Color.black);
showStatus("Mouse Exited");
repaint();
}
public void mousePressed(MouseEvent m)
{
X=10;
Y=20;
msg="mouse pressed";
setBackground(Color.green);
repaint();
}
public void mouseReleased(MouseEvent m)
{
X=10;
Y=20;
msg="mouse released";
setBackground(Color.blue);
repaint();
}
public void mouseMoved(MouseEvent m)
{
X=m.getX();
Y=m.getY();
msg="mouse moved";
setBackground(Color.white);
showStatus("Mouse Moved");
repaint();
}
public void mouseDragged(MouseEvent m)
{
msg="mouse dragged";
setBackground(Color.yellow);
showStatus("Mouse Moved"+m.getX()+" "+m.getY());
repaint();
}
public void mouseClicked(MouseEvent m)
{
msg="mouse clicked";
setBackground(Color.pink);
showStatus("Mouse Clicked");
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,X,Y);
}
}








mouse.html
<applet code="Mouse" width=200 height=60>
</applet>


user defined exception

Example 1:


class clexc extends Exception
{
public clexc(String s)
{

super(s);
}
}

public class clex
{

public static void main(String args[])
{
try
{

throw new clexc("my exception");
}
catch (clexc ex)
{
System.out.println("exception Caught");

System.out.println(ex.getMessage());
}
}
}


output::

D:\>javac clex.java

D:\>java clex
exception Caught
my exception

D:\>




Example 2:

class clexc extends Exception
{    private int v;
public clexc(String s)
{

super(s);
}
     public clexc(int a){v=a;}
     public String toString(){ return "exc"+v+"pp";}


}

public class clex
{
static void compute(int a) throws clexc
        { System.out.println("compute function"+a);
          if(a>10)
             throw new clexc(a);
          System.out.println("no throw");
           
        }
public static void main(String args[])
{
try
{

compute(1);
}
catch (clexc ex)
{
System.out.println("exception Caught");

System.out.println(ex.getMessage());
}
}
}



D:\>javac clex.java

D:\>java clex
compute function1
no throw

D:\>


Example 3:

class clexc extends Exception
{    private int v;
public clexc(String s)
{

super(s);
}
     public clexc(int a){v=a;}
     public String toString(){ return "exc"+v+"pp";}


}

public class clex
{
static void compute(int a) throws clexc
        { System.out.println("compute function"+a);
          if(a>10)
             throw new clexc(a);
          System.out.println("no throw");
           
        }
public static void main(String args[])
{
try
{

compute(11);
}
catch (clexc ex)
{
System.out.println("exception Caught");

System.out.println(ex.getMessage());
}
}
}

output:


D:\>javac clex.java

D:\>java clex
compute function11
exception Caught
null

D:\>



Wednesday, April 24, 2019

sub package



step1:: go to D:\p1\p2

step2: p.java


package p1.p2;
import java.util.Scanner;
public class p
{
public void f(int x,int y){
System.out.println(x);
System.out.println(y);
}
}

step3:
D:\

step4 ::cl5.java

import p1.p2.p;
import java.util.Scanner;
class cl4 extends p
{
}


public class cl5
{
public static void main(String args[])
{
cl4 ob=new cl4();
ob.f(2,3);
}
}



step5:

D:\>cd p1

D:\p1>cd p2

D:\p1\p2>javac p.java

D:\p1\p2>cd ..

D:\p1>cd ..

D:\>javac cl5.java

D:\>java cl5
2
3

D:\>java cl5

package

1. single level package -                        text - click here


                                                               video - step by step video 



2.       two level package                            text - click here                                                                                                                                                                                        




Example 3 ::  two level                                                                                                                                                                                                                                      



4. difference between default and public                                                                                                                                                                                                             

                                                                          






hierarchical interface


                                       



interface A
{
public void input();
}


interface B extends A
{
void output();
}

interface c extends A
{
void output();
}




class cl1 implements B
{
int a,b;
public void input()
{
a=3;
b=7;
}
public void output()
{
int min;
min=a+b;
System.out.println(min);
}
}




class cl2 implements c
{
int a,b;
public void input()
{
a=4;
b=8;
}
public void output()
{
int min;
min=a-b;
System.out.println(min);
}
}
public class diya1
{
public static void main(String args[])
{

cl1 ob1=new cl1();
ob1.input();
ob1.output();

cl2 ob2=new cl2();
ob2.input();
ob2.output();
}
}


D:\>javac diya1.java

D:\>java diya1
10
-4

D:\>

                                                                                                                                                                            edited by diya