Thursday, December 10, 2009

C++-->STORE NAMES OF N STUDENTS INTO AN ARRAY

Store names of n students into an array and then search for a particular name

#include

#include

#include

#include

void main()

{

int i,n,big;

int flag;

char name[100][25];

char t[25];

cout<<”Enter how many elements : “;

cin>>n;

for(i=0;i
gets(name[i]);



cout<<”Enter a name for search : “;

gets(t);

flag=0;

for(i=0;i
if(strcmp(name[i],t==0)

{

flag=1;

break;

}

if(flag= =1)

cout<<”The given name is found in the position “<
else

cout<<”The given name is not found”;

getch();

}

Tuesday, December 8, 2009

C++->BIGGEST NUMBER

Write a program to store n numbers into an array and find the biggest number along with its position
#include

#include

void main()

{

int ar[100],i,n,big;

cout<<”Enter how many elements : “;

cin>>n;

cout<<”Enter the elements \n”;

for(i=0;i
cin>>ar[i];











big=ar[0];

for(i=1;i
if(ar[i]>big)

big=ar[i];

cout<<”Biggest number is : “<
getch();

}

Monday, December 7, 2009

C++->PRIME NUMBERS

Find the prime numbers between 1 and 100

#include

#include

#include

void main()

{

int i,j,n,p;

clrscr();

int flag;

for(i=1;i<=100;i++)

{

p=i;

flag=1;

for(j=2;j<=p/2;j++)

if((p%j)= = 0)

{

flag=0;

break;

}

if(flag= = 1)

cout<
}

getch();

}

Sunday, December 6, 2009

C++->SERIES FOR n ROWS

Write a program to print the following series for n rows.

a
a b
a b c
a b c d
. . . nth row. . .

#include
#include
void main()
{
int i,j,l,n;
char ch;
clrscr();
cout<<”Enter how many lines : “;
cin>>n;
l=40;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
cout<<” “;
for(j=1,ch=’a’;j<=I;j++,ch++)
cout<<” “< l=l-1;
}
getch();
}

Saturday, December 5, 2009

C++->SUM DIFFERENCE PRODUCT AND QUOTIENT

Write a program to find the sum, difference, product and quotient of two numbers using C++

#include
#include
#include
void main()
{
char ch;
float a,b,r;
clrscr();
cout<<”\n1. Sum”; cout<<”\n2. Difference”; cout<<”\n3. Product”; cout<<”\n4. Quotient”; cout<<”\n\nEnter your choice……”; ch=getchar(); switch(ch) { case ‘1’: cout<<”Enter two numbers : “; cin>>a>>b;
r=a+b;
cout<<”Sum : “<>a>>b;
r=a-b;
cout<<”Difference : “<>a>>b;
r=a*b;
cout<<”Product : “<>a>>b;
r=a/b;
cout<<”Quotient : “< break;
default:
cout<<”Invalid choice “;
}
getch();
}

Friday, December 4, 2009

C++->Capital letter, Small letter, a Digit or a Special character.

Input a character and check whether it is a Capital letter, Small letter, a Digit or a Special character.
#include
void main()
{
char ch;
ch=getchar();
if(ch >= ’A’ && ch <= ’Z’)
cout<<”Capital letter”;
else
if(ch >= ’a’ && ch <= ’z’)
cout<<”Small letter”;

else
if(ch >= ’0’ && ch <= ’9’)
cout<<”Digit”;
else
cout<<”Special character ”;
}

Saturday, August 29, 2009

C++-FIBONACCI SERIES

#include
#include

main()
{
const unsigned long limit=4294967295;
unsigned long next=0;
unsigned long last=1;
long sum;

clrscr();

cout<<"\n\n This program will print the Fibonacci series :\n\n ";
while(next {
cout< sum=next+last;
next=last;
last=sum;
}
getch();
}

C++ CALCULATOR

#include
#include
using namespace std;
float mult(float num1,float num2);
float add(float num1,float num2);
float sub(float num1,float num2);
float divide(float num2,float num2);
int main()
{
int choice;
float num1,num2;
cout<<"---------------------------------------------"< cout<<" CALCULATOR"< cout<<"---------------------------------------------"< cout<<" Make a selection:"< cout<<" 1.Division"< cout<<" 2.Adding"< cout<<" 3.Subtraction"< cout<<" 4.multiplication"< cout<<"
YOUR CHIOCE IS: ";
cin>>choice;
switch(choice)
{
case 1:
cout<<"Enter the two numbers you want to divide, divisor first!: ";
cin>>num1>> num2;
cin.ignore();
cout<<" "< cin>>num1>> num2;
cin.ignore();
cout<<" "< break;
case 3:
cout<<"Enter the two numbers you want to subtract”;
cin>>num1>> num2;
cin.ignore();
cout<<" "< break;
case 4:
cout<<"Enter the two numbers you want to multiply: ";
cin>>num1>>num2;
cin.ignore();
cout<<" "< break;
default:
cout<<"Invalid Entry!"< cin.ignore();
break;
}
cin.ignore();
return 0;
}
float mult(float num1,float num2)
{
return (num1*num2);
}
float add(float num1,float num2)
{
return (num1+num2);
}
float sub(float num1,float num2)
{
return (num1-num2);
}
float divide(float num1,float num2)
{
return (num1/num2);
}

Tuesday, May 26, 2009

ABOUT C++

ABOUT C++
C++ is a general purpose programming language invented in the early 1980s by Bjarne Stroustrap at Bell Labs. It is similar to C, invented in the early 1970s by Dennis Ritchie, but is a safer language than C and includes modern programming techniques such as object oriented programming.
The purpose of C++ is to precisely define a series of operations that a computer can perform to accomplish a task. Most of these operations involve manipulating numbers and text, but anything that the computer can physically do can be programmed in C++. Computers have no intelligence- they have to be told exactly what to do and this is defined by the programming language you use. Once programmed they can repeat the steps as many times as you wish at very high speed. Modern PCs are so fast they can count to a billion in a second or two.
What can a C++ program do?
Typical programming tasks includes putting data into a database or pulling it out, displaying high speed graphics in a game or video, controlling electronic devices attached to the PC or even playing music and/or sound effects. You can even write software to generate music or help you compose.
Is C++ the best programming language?
Some computer languages were written for a specific purpose. Java was originally devised to control toasters, C for programming Operating Systems, Pascal to teach good programming techniques but C++ is a general purpose language and well deserves the "Swiss Pocket Knife of Languages" nickname. There are some tasks that can be done in C++ but not very easily, for example designing GUI screens for applications. Other languages like Visual Basic, Delphi and more recently C# have GUI design elements built in to them and so are better suited for this type of task. Also some scripting languages that provide extra programmability to applications like MS Word and even Photoshop tend to be done in variants of Basic, not C++.

Followers