Translate

Friday, 31 August 2012

Flow Charts


Flowchart
Flowchart is the graphical representation of an algorithm. It is used to show all the steps of an algorithm in a sequence pictorially. An algorithm may be converted to a flowchart. The flowchart is then converted into a program written in any programming language.

Advantages of Flowcharts
Flowchart is used for the following reasons:
1.    Flowchart represents an algorithm in graphical symbols.
2.    It shows the steps of an algorithm in an easy way.
3.    It is used to understand the flow of the program.


Flowchart Symbols
Following are the symbols used in Flowchart
1.    Start/End
Oval symbol is used to represent the start or end of the flowchart.
 2.    Input/Output
Parallelogram symbol is used to represent an input or output step.

3.     Process
Rectangle symbol is used to represent a process step. A process may be a calculation or assignment etc.

4.     Selection           
Diamond symbol is used to represent a selection step. A condition is given in the diamond. If condition is true then flow of control will go in one direction. If condition is false then control will go in other direction.

5. Flow Lines    
Arrow symbols are used to represent the direction of flow in the flowchart. There are four types of flow lines.

6. Connector      
Circle symbol is used to combine different flow lines.

Examples:
Example 1
Develop a flowchart to input two numbers from the user, calculate its sum and then display the result.


Example 2
Develop a flowchart to input 5 numbers from the user, calculate its average and then display the result.

Subscribe to lillian
Powered by groups.yahoo.com

  

Questions And Answers In C++

Question : What is run-time error, logical error and syntax error?

Answer : Syntax error - The errors which are traced by the compiler during compilation, due to wrong grammar for the language used in the program, are called syntax errors.
For example, cin<<a; // instead of extraction operator insertion operator is used.
Run time Error - The errors encountered during execution of the program, due to unexpected input or output are called run-time error.
For example - a=n/0; // division by zero

Logical Error - These errors are encountered when the program does not give the desired output, due to wrong logic of the program.
For example : remainder = a+b // instead of using % operator + operator is used.

Question : What is the role of #include directive in C++?

Answer : The preprocessor directive #include tells the complier to insert another file into your source file. In effect, #include directive is replaced by the contents of the file indicated.

Question : What is the role of #define in C++?

Answer : It is a preprocessor directive to define a macro in a C++ program. Macros provide a mechanism for token replacement with or without a set of formal, function line parameters. For example :
#define PIE 3.1416
#define AVG(A,B,C) (A+B+C)/3

Question : What is the difference between while and do-while loop?

Answer : While is an Entry Controlled Loop, the body of the loop may not execute even once if the test expression evaluates to be false the first time, whereas in do..while, the loop is executed at least once whether the condition holds true the first time or not. more details


Question : What is the difference between local variable and global variable?

Answer : Local variables are those variables which are declared within a function or a compound statement and these variables can only be used within that function/scope. They cannot be accessed from outside the function or a scope of it's declaration. This means that we can have variables with the same names in different functions/scope. Local variables are local to the function/scope in which they are declared.
Global variables are those variables which are declared in the beginning of the program. They are not declared within a function. So, these variables can be accessed by any function of the program. So, global variables are global to all the functions of the program.
 


Question : What is pointer?

Answer : Pointer is an address of a memory location. A variable, which holds an address of a memory location, is known as a Pointer variable (or Simply Pointer). For example int *P; more details

Wednesday, 29 August 2012

//Addition of two POLYNOMIAL's

#include<iostream.h>
#include<conio.h>
void main()
{
    int co[10],i,p,k,co2[10],co1[10];
    char po[9];
    clrscr();
    for(i=0;i<10;i++)
    {
        co[i]=0;
    }
    cout<<"\nPlease enter the power of the polynomial\ni.e. the highiest power"<<endl;
    cin>>p;
    cout<<"\nPlease enter the polynomial \nAs:2 x*x+ 3 x+ 7\n"<<endl;
    for(i=0;i<p+1;i++)
    {
        cin>>co[i];
        if(i!=p)
        cin>>po;
    }
    for(i=0;i<p+1;i++)
    {
        cout<<co[i];
        for(k=0;k<p-i;k++)
        {
            cout<<"x";
            if(k!=(p-(i+1)))
            cout<<"*";
        }
        if(i!=p)
        cout<<"+";
    }
    cout<<"\nPlease enter the power of the polynomial\ni.e. the highiest power"<<endl;
    cin>>p;
    cout<<"\nPlease enter the polynomial \nAs:2 x*x+ 3 x+ 7\n"<<endl;
    for(i=0;i<p+1;i++)
    {
        cin>>co2[i];
        if(i!=p)
        cin>>po;
    }
    for(i=0;i<p+1;i++)
    {
        cout<<co2[i];
        for(k=0;k<p-i;k++)
        {
            cout<<"x";
            if(k!=(p-(i+1)))
            cout<<"*";
        }
        if(i!=p)
        cout<<"+";
    }
         cout<<endl;
    for(i=0;i<=p;i++)
    {
        co1[i]=co2[i]+co[i];
    }
    cout<<"\nThe addition of polynomial is:....."<<endl;
     for(i=0;i<p+1;i++)
    {
        cout<<co1[i];
        for(k=0;k<p-i;k++)
        {
            cout<<"x";
            if(k!=(p-(i+1)))
            cout<<"*";
        }
        if(i!=p)
        cout<<"+";
    }
    getch();
}

//Addition of two POLYNOMIAL's

#include<iostream.h>

#include<conio.h>

void main()

{

    int co[10],i,p,k,co2[10],co1[10];

    char po[9];

    clrscr();

    for(i=0;i<10;i++)

    {

        co[i]=0;

    }

    cout<<"\nPlease enter the power of the polynomial\ni.e. the highiest power"<<endl;

    cin>>p;

    cout<<"\nPlease enter the polynomial \nAs:2 x*x+ 3 x+ 7\n"<<endl;

    for(i=0;i<p+1;i++)

    {

        cin>>co[i];

        if(i!=p)

        cin>>po;

    }

    for(i=0;i<p+1;i++)

    {

        cout<<co[i];

        for(k=0;k<p-i;k++)

        {

            cout<<"x";

            if(k!=(p-(i+1)))

            cout<<"*";

        }

        if(i!=p)

        cout<<"+";

    }

    cout<<"\nPlease enter the power of the polynomial\ni.e. the highiest power"<<endl;

    cin>>p;

    cout<<"\nPlease enter the polynomial \nAs:2 x*x+ 3 x+ 7\n"<<endl;

    for(i=0;i<p+1;i++)

    {

        cin>>co2[i];

        if(i!=p)

        cin>>po;

    }

    for(i=0;i<p+1;i++)

    {

        cout<<co2[i];

        for(k=0;k<p-i;k++)

        {

            cout<<"x";

            if(k!=(p-(i+1)))

            cout<<"*";

        }

        if(i!=p)

        cout<<"+";

    }

         cout<<endl;

    for(i=0;i<=p;i++)

    {

        co1[i]=co2[i]+co[i];

    }

    cout<<"\nThe addition of polynomial is:....."<<endl;

     for(i=0;i<p+1;i++)

    {

        cout<<co1[i];

        for(k=0;k<p-i;k++)

        {

            cout<<"x";

            if(k!=(p-(i+1)))

            cout<<"*";

        }

        if(i!=p)

        cout<<"+";

    }

    getch();

}