Sunteți pe pagina 1din 11

Assignments on C++

Program
1. To find factorial of a given number.
2. To demo Friend Function.
3. To demo for enumerated data to find sum, difference, product, & division of 2 numbers.
4. To add 2 complex numbers using Operator Overloading.
5. To find sum of 2 numbers of type integer & double using function Overloading.
6. To maintain candidate information.
7. To calculate simple & compound interest.
8. To show object as argument
9. To calculate the area & circumference of the circle using constructor.
10. To calculate the square of a given number using inline function.
11. To illustrate single inheritance in public mode.
12. To illustrate object created and destroyed.
13. To illustrate multiple inheritance to find product of 2 numbers.
14. To demo an object of class type & initialization of its members using overloaded
function.
15. To overload volume ( ) function using function overloading.
16. To find maximum data item of similar data type using function template.
17. To illustrate the definition & declaration of a class template for accepting 2 numbers &
find their sum.
18. To illustrate virtual function & object pointer using runtime polymorphism.
19. To illustrate set type, set position, set precision & set fill function.
20. To illustrate a disc file for reading its counts.

Design algorithm & draw flowchart for the following:


Write a C++ Program to find factorial of a given number.
Write a C++ Program to illustrate virtual function & object pointer using runtime polymorphism.

Design algorithm & draw flowchart for the following:


Write a C++ Program to calculate simple & compound interest.
Write a C++ Program to illustrate the definition & declaration of a class template for accepting 2
numbers & find their sum.
Design algorithm & draw flowchart for the following:
Write a C++ Program to maintain candidate information.
Write a C++ Program to illustrate set type, set position, set precision & set fill function.
Design algorithm & draw flowchart for the following:
Write a C++ Program to demo Friend Function.
Write a C++ Program to illustrate a disc file for reading its counts.
Design algorithm & draw flowchart for the following:
Write a C++ Program to demo for enumerated data to find sum, difference, product, & division
of 2 numbers.
Write a C++ Program to illustrate object created and destroyed.

Design algorithm & draw flowchart for the following:


Write a C++ Program demo for enumerated data to find sum, difference, product, & division of 2
numbers.
Write a C++ Program to overload volume ( ) function using function overloading.

Design algorithm & draw flowchart for the following:


Write a C++ Program to calculate the area & circumference of the circle using constructor.
Write a C++ Program to illustrate single inheritance in public mode.
Design algorithm & draw flowchart for the following:
Write a C++ Program to calculate the square of a given number using inline function.
Write a C++ Program to overload volume ( ) function using function overloading.

Design algorithm & draw flowchart for the following:


Write a C++ Program to find sum of 2 numbers of type integer & double using function
Overloading.
Write a C++ Program to illustrate object created and destroyed.

Design algorithm & draw flowchart for the following:


Write a C++ Program demo an object of class type & initialization of its members using
overloaded function.
Write a C++ Program find maximum data item of similar data type using function template.

Design algorithm & draw flowchart for the following:


Write a C++ Program to find factorial of a given number.
Write a C++ Program to illustrate virtual function & object pointer using runtime polymorphism.
Design algorithm & draw flowchart for the following:
Write a C++ Program to calculate simple & compound interest.
Write a C++ Program to illustrate the definition & declaration of a class template for accepting 2
numbers & find their sum.
Design algorithm & draw flowchart for the following:
Write a C++ Program to maintain candidate information.
Write a C++ Program to illustrate set type, set position, set precision & set fill function.
Design algorithm & draw flowchart for the following:
Write a C++ Program to demo Friend Function.
Write a C++ Program to illustrate a disc file for reading its counts.
Design algorithm & draw flowchart for the following:
Write a C++ Program to demo for enumerated data to find sum, difference, product, & division
of 2 numbers.
Write a C++ Program to illustrate object created and destroyed.

Design algorithm & draw flowchart for the following:


Write a C++ Program demo for enumerated data to find sum, difference, product, & division of 2
numbers.
Write a C++ Program to overload volume ( ) function using function overloading.

Design algorithm & draw flowchart for the following:


Write a C++ Program to calculate the area & circumference of the circle using constructor.
Write a C++ Program to illustrate single inheritance in public mode.

Design algorithm & draw flowchart for the following:


Write a C++ Program to calculate the square of a given number using inline function.
Write a C++ Program to overload volume ( ) function using function overloading.

Design algorithm & draw flowchart for the following:


Write a C++ Program to find sum of 2 numbers of type integer & double using function
Overloading.
Write a C++ Program to illustrate object created and destroyed.

Design algorithm & draw flowchart for the following:


Write a C++ Program demo an object of class type & initialization of its members using
overloaded function.
Write a C++ Program find maximum data item of similar data type using function template.

Design algorithm & draw flowchart for the following:


Write a C++ Program to find factorial of a given number.
Write a C++ Program to illustrate virtual function & object pointer using runtime polymorphism.
Design algorithm & draw flowchart for the following:
Write a C++ Program to calculate simple & compound interest.
Write a C++ Program to illustrate the definition & declaration of a class template for accepting 2
numbers & find their sum.
Design algorithm & draw flowchart for the following:
Write a C++ Program to maintain candidate information.
Write a C++ Program to illustrate set type, set position, set precision & set fill function.
Design algorithm & draw flowchart for the following:
Write a C++ Program to demo Friend Function.
Write a C++ Program to illustrate a disc file for reading its counts.
Design algorithm & draw flowchart for the following:

Write a C++ Program to demo for enumerated data to find sum, difference, product, & division
of 2 numbers.
Write a C++ Program to illustrate object created and destroyed.

Design algorithm & draw flowchart for the following:


Write a C++ Program demo for enumerated data to find sum, difference, product, & division of 2
numbers.
Write a C++ Program to overload volume ( ) function using function overloading.

Design algorithm & draw flowchart for the following:


Write a C++ Program to calculate the area & circumference of the circle using constructor.
Write a C++ Program to illustrate single inheritance in public mode.
Design algorithm & draw flowchart for the following:
Write a C++ Program to calculate the square of a given number using inline function.
Write a C++ Program to overload volume ( ) function using function overloading.

Design algorithm & draw flowchart for the following:


Write a C++ Program to find sum of 2 numbers of type integer & double using function
Overloading.
Write a C++ Program to illustrate object created and destroyed.

Design algorithm & draw flowchart for the following:


Write a C++ Program demo an object of class type & initialization of its members using
overloaded function.
Write a C++ Program find maximum data item of similar data type using function template.

JAVA ASSIGNMENTS
Program for counting no. of Chars, Words and Lines in a file
import java.lang.*;
import java.io.*;
import java.util.*;
class WordCount
{
public static void main(String arg[]) throws Exception
{
int char_count=0;
int word_count=0;
int line_count=0;
String s;
StringTokenizer st;
BufferedReader buf=new BufferedReader(new
InputStreamReader(System.in));
System.out.print("Enter filename : ");
s=buf.readLine();
buf=new BufferedReader(new FileReader(s));
while((s=buf.readLine())!=null)
{
line_count++;
st=new StringTokenizer(s," ,;:.");
while(st.hasMoreTokens())
{
word_count++;
s=st.nextToken();
char_count+=s.length();
}
}
System.out.println("Character Count : "+char_count);
System.out.println("Word Count : "+word_count);

System.out.println("Line Count : "+line_count);


buf.close();
}
}
Program to check the input characcter for uppercase, lowercase, no. of digits
and other characters
import java.io.*;
class InputDiagnosis{
public static void main(String args[]) throws IOException
{
char ch;
int digit=0;
int upper=0;
int lower=0;
int other=0;
BufferedReader inputstream =new BufferedReader(new
InputStreamReader(System.in));
System.out.println(" Type some text. When done, press Enter to Quit:");
do{
ch=(char) inputstream.read();
if(Character.isDigit(ch))
digit++;
else if(Character.isUpperCase(ch))
upper++;
else if(Character.isLowerCase(ch))
lower++;
else
other++;
}while(ch !='');
System.out.println("No Of Digits:" +digit);
System.out.println("No Of Uppercase Characters:" +upper);
System.out.println("No Of Lowercase Characters:" +lower);
System.out.println("No Of Other Characters:" +other);

}
}
Fibonacci numbers (Right side)
import java.text.*;
public class TestRight {
public static void main(String args[]) {
long f1 = 1;
long f2 = 1;
RightFormat rf = new RightFormat(20);
System.out.println("Test of RightFormat(20) on Fibonacci numbers:");
for(int ix = 0; ix < 32; ix++) {
System.out.println(rf.format(Long.toString(f1)));
System.out.println(rf.format(Long.toString(f2)));
f1 = f1 + f2;
f2 = f2 + f1;
}
}
}
Demonstrating the runnable interface
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class RandomCharacters extends JApplet implements Runnable, ActionListener
{
private String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private JLabel outputs[];
private JCheckBox checkboxes[];
private final static int SIZE = 3;
private Thread threads[];
private boolean suspended[];
public void init()
{
outputs = new JLabel[ SIZE ];
checkboxes = new JCheckBox[ SIZE ];
threads = new Thread[ SIZE ];

suspended = new boolean[ SIZE ];


Container c = getContentPane();
c.setLayout( new GridLayout( SIZE, 2, 5, 5 ) );
for ( int i = 0; i < SIZE; i++ )
{
outputs[ i ] = new JLabel();
outputs[ i ].setBackground( Color.green );
outputs[ i ].setOpaque( true );
c.add( outputs[ i ] );
checkboxes[ i ] = new JCheckBox( "Suspended" );
checkboxes[ i ].addActionListener( this );
c.add( checkboxes[ i ] );
}
}
public void start()
{
// create threads and start every time start is called
for ( int i = 0; i < threads.length; i++ )
{
threads[ i ] = new Thread( this, "Thread " + (i + 1) );
threads[ i ].start();
}
}
public void run()
{
Thread currentThread = Thread.currentThread();
int index = getIndex( currentThread );
char displayChar;
while ( threads[ index ] == currentThread )
{
// sleep from 0 to 1 second
try
{
Thread.sleep( (int) ( Math.random() * 1000 ) );
synchronized( this )
{
while ( suspended[ index ] && threads[ index ] ==
currentThread )
wait();

}
}
catch ( InterruptedException e )
{
System.err.println( "sleep interrupted" );
}
displayChar = alphabet.charAt( (int) ( Math.random() * 26 ) );
outputs[ index ].setText( currentThread.getName() +
": " + displayChar );
}
System.err.println( currentThread.getName() + " terminating" );
}
private int getIndex( Thread current )
{
for ( int i = 0; i < threads.length; i++ )
if ( current == threads[ i ] )
return i;
return -1;
}
public synchronized void stop()
{
// stop threads every time stop is called
// as the user browses another Web page
for ( int i = 0; i < threads.length; i++ )
threads[ i ] = null;
notifyAll();
}
public synchronized void actionPerformed( ActionEvent e )
{
for ( int i = 0; i < checkboxes.length; i++ )
{
if ( e.getSource() == checkboxes[ i ] )
{
suspended[ i ] = !suspended[ i ];
outputs[ i ].setBackground( !suspended[ i ] ? Color.green :
Color.red );
if ( !suspended[ i ] )

notify();
return;
}
}
}
}

S-ar putea să vă placă și