NBA - Boston Celtics

Sunday, 18 November 2012

Print 1,2,4,8,16,32,64,128


#include<iostream.h>
void main()
{
float sales,comm;
cout<<"enter the sale ";
cin>>sales;
if(sales>=5000)
if(sales>=12000)
if(sales>=22000)
if(sales>=3000)
comm=sales*0.15;
else
comm=sales*0.1;
else
comm=sales*0.07;
else
comm=sales*0.03;
else
comm=0;
cout<<"commision of the sale is "<<comm;
}

FIND OUT COMMISSION



#include<iostream.h>
void main()
{
float sales,comm;
cout<<"enter the sale ";
cin>>sales;
if(sales>=5000)
if(sales>=12000)
if(sales>=22000)
if(sales>=3000)
comm=sales*0.15;
else
comm=sales*0.1;
else
comm=sales*0.07;
else
comm=sales*0.03;
else
comm=0;
cout<<"commission of the sale is "<<comm;
}


Check whether character entered is number or alphabet


#include<iostream.h>
void main()
{
char a;
cout<<"enter a charchter : ";
cin>>a;
if(a>='a'&&a<='z')
{
cout<<"you have entered a alphabet ..";
}
else
{
cout<<"you have entered a number";
}
}

TABLE USING FUNCTION


#include<iostream.h>
int a,ans,result;
int table(int a);
void main()
{
cout<<"enter a number to find its table : ";
cin>>a;
int result;
result=table(a);
}
int table(a)
{
for(int i=1;i<11;i++)
{
cout<<a<<"*"<<i<<"="<<a*i<<"\n";
}
}

Sunday, 11 November 2012

Word Processor......(begin)


#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<ctype.h>
void main()
{
char string[80];
clrscr();
cout<<"Enter multiple sentences:";
gets(string);
string[0]=toupper(string[0]);
for(int i=0; string[i]!='\0'; ++i)
{
if(string[i]=='.')
{
string[i+2]=toupper(string[i+2]);
}
}
clrscr();
cout<<"Updated string is: \n"<<string;
getch();
}


Monday, 22 October 2012

to upper


#include<iostream.h>
#include<string.h>
#include<ctype.h>
void main()
{
char a[80];
cout<<"enter a line :";
for(int i=0;i<80;i++)
{
cin>>a[i];
a[i]=toupper(a[i]);
cout<<a[i];
}
}


Password


#include<iostream.h>
#include<string.h>
void main()
{
char line[80];
cout<<"enter the password ";
for(int i=0;i<80;i++)
{
cin.getline(line,80);

if(strcmp(line,"gaurav"))
{
cout<<"sorry";
}
else
{
cout<<"ok";
}
}
}


palindrome


#include<iostream.h>
#include<conio.h>
void main()
{
int digit,rev=0,num,a;
cout<<"enter a no. : ";
cin>>a;
num=a;
do
{
digit=num%10;
rev=(rev*10)+digit;
num=num/10;
}while(num!=0);
cout<<"reversed no. is"<<rev;
if(a==rev)
cout<<"\n"<<a<<" is a plaindrome \n";
else
cout<<"\n"<<a<<" is not a palindrome";
}

Fibonacci series using Fuction


#include<iostream.h>
int fib(int n);
int i,first=0,second=1,third,n;
void main()
{
cout<<"enter the value of n to find fibonacci series : ";
cin>>n;
cout<<first<<","<<second;
int result;
result=fib(n);
}
int fib(int n)
{
for(i=1;i<=n;i++)
{
third=first+second;
cout<<","<<third;
first=second;
second=third;
}
}


Saturday, 20 October 2012

DIAMOND


#include<conio.h>
int main()
{
clrscr();
  int n, c, k, space = 1;

  printf("Enter number of rows\n");
  scanf("%d", &n);

  space = n - 1;

  for (k = 1; k <= n; k++)
  {
for (c = 1; c <= space; c++)
printf(" ");

space--;

for (c = 1; c <= 2*k-1; c++)
printf("*");

printf("\n");
  }

  space = 1;

  for (k = 1; k <= n - 1; k++)
  {
for (c = 1; c <= space; c++)
printf(" ");

space++;

for (c = 1 ; c <= 2*(n-k)-1; c++)
printf("*");

printf("\n");
  }
}


SUM OF FIRST !) NATURAL NO.s


#include<iostream.h>
#include<conio.h>
void main()
{
int sum=0;
for(int i=1;i<=10;i++)
sum=sum+i;
cout<<"sum of first ten natural no. is = "<<sum;
}

ROOTS OF QUADRATIC EQUATION


#include<iostream.h>
#include<math.h>
void main()
{
int x,x1,d,d1,a,b,c;
cout<<"enter a,b,c of quadratic eqution (ax2+ bx +c) :";
cin>>a>>b>>c;
d=b*b-4*a*c;
d1=sqrt(d);
x=(-b+d1)/2*a;
x1=(-b-d1)/2*a;
cout<<"roots of the quadratic eqution are :";
cout<<x<<" "<<x1;
}