Wednesday, March 16, 2011

SIMPLE PATTERN USING LOOP

#include<iostream>
using namespace std;
int main()
{
char ch;                                           //character variable
ch=65;
for(int x=1;x<=5;x++)
    {
    for(int y=1;y<=x;y++)
    cout<<ch<<" ";
    ch=ch+1;
    cout<<endl;
    }
return 0;
}

The compilation of the above program....

g++ -o<the name that you want compile> <file name>





return 0;
}

Sunday, February 27, 2011

convert millimeters into feet & inches

#include<iostream>
using namespace std;
int main()
{
        int mm,feet,inches;
        cout<<"Enter the length in millimeters\n" ;          //instructions
        cin>>mm;                                                         //input
        feet=(mm/25)/12;                                            //calculation
inches=(mm/25)%12;                                      //calculation
        cout<<"length = "<<feet<<" feet "<<inches<<" incheses"<<endl;
        return 0;
}





The compilation of the above program....

g++ -o<the name that you want compile> <file name> 

Friday, February 25, 2011

simple calculation - Fahrenheits to Celsius

#include<iostream>
using namespace std;
int main()
{
double celsius, Fahrenheits ;                                                          //declaration of variable
cout<<" Enter Fahrenheits value\n";                                               //command
cin>>Fahrenheits ;                                                                        // input
celsius = (Fahrenheits -32)*5.0/9.0;                                             // calculation
cout<<Fahrenheits <<" degrees Fahrenheits is "<<celsius;
cout<<" degree celsius.\n";
return 0;
}



The compilation of the above program....

g++ -o<the name that you want compile> <file name>







ncurses program with color..

#include<ncurses.h>
int main()
{
initscr();
start_color();                                                               //to add color effect
init_pair(1,COLOR_GREEN,COLOR_BLUE);        //declaring color(<pair no>,<text color>,
                                                                                               <background color>)                                                                        
attrset (COLOR_PAIR(1));                                     //set the colors
move(12,30);
printw("My first color prog");
getch();
endwin();
return 0;
}



The compilation of the above program....

g++ -o<the name that you want compile> <file name> -lncurses









simple ncurses program

#include <ncurses.h>
using namespace std;
int main()
{
 initscr();
move(12,30);                                               //the location of the output
printw("First ncurses programe\n");              //output
getch();
endwin();
return 0;
}



The compilation of the above program....

g++ -o<the name that you want compile> <file name> -lncurses






Add caption