Wednesday 26 April 2017

home work display straick

#include <iostream>
using namespace std;
int main()
{
int space = 0, star = 5;
for (int i = 1; i <=5; i++)
{
for ( int j = 0; j <space; j++)
{
cout << " ";
}
for (int j = 0; j < star; j++)
{
cout << "*";
}
cout << endl;
space++;
star--;
}

return 0;
}
.........................................................................
#include <iostream>
using namespace std;
int main()
{
int space = 5, star = 1;
for (int i = 1; i <=5; i++)
{
for ( int j = 1; j <space; j++)
{
cout << " ";
}
for (int j = 0; j < star; j++)
{
cout << "*";
}
cout << endl;
space--;
star++;
}

return 0;
}
.............................................................
#include <iostream>
using namespace std;
int main()
{
int space = 5, star = 1;
for (int i = 1; i <=5; i++)
{
for ( int j = 1; j <space; j++)
{
cout << " ";
}
for (int j = 0; j < star; j++)
{
cout << "*";
}
for (int j = 1; j < star; j++)
{
cout << "*";
}
cout << endl;
space--;
star++;
}

return 0;
.............................................................................
#include <iostream>
using namespace std;
int main()
{

int space1 = 1, star1 =5 ;
for (int i = 1; i <= 5; i++)
{
for (int j = 1; j <space1; j++)
{
cout << " ";
}
for (int j = 0; j < star1; j++)
{
cout << "*";
}
for (int j = 1; j < star1; j++)
{
cout << "*";
}
cout << endl;
space1++;
star1--;
}
return 0;
}
}
.............................................................................
#include <iostream>
using namespace std;
int main()
{
int space = 5, star = 1;
for (int i = 1; i <=5; i++)
{
for ( int j = 1; j <space; j++)
{
cout << " ";
}
for (int j = 0; j < star; j++)
{
cout << "*";
}
for (int j = 1; j < star; j++)
{
cout << "*";
}
cout << endl;
space--;
star++;
}
int space1 = 1, star1 =5 ;
for (int i = 1; i <= 5; i++)
{
for (int j = 1; j <space1; j++)
{
cout << " ";
}
for (int j = 0; j < star1; j++)
{
cout << "*";
}
for (int j = 1; j < star1; j++)
{
cout << "*";
}
cout << endl;
space1++;
star1--;
}
return 0;
}
............................................................

Tuesday 25 April 2017

c++ prog..
..................................................................
#include <iostream>
using namespace std;
int main()
{
int n,m,l;
cout << " enter the first number ";
cout<< endl;
cin >> n;
if (n > 0)
{
cout << "enter  the second number ";
cout << endl;
cin >> m;

if (m > 0)
{

l = m + n;
cout << "the sum is =" << l;
}
else
{
cout << "you have entered the negative number";
}
}

else
{
cout << "you have entered the negative number";
}

return 0;
}
........................................................................
#include <iostream>
using namespace std;
int main()
{
int a, b, result, i,count;
cout << "enter the number whose table you want to display";
cout << endl;
cin >> a;
cout << "enter the size of table";
cout << endl;
cin >> i;
for (count = 1; count <= i; count++)
{
result = a*count;

cout << a << "*" << count << "="<<result;
cout << endl;
}
return 0;
}
..........................................................................
#include <iostream>
using namespace std;
int main()
{
cout << "    * \n   ***\n  *****\n   ***\n    *";
return 0;
}

...................................................................
#include <iostream>
using namespace std;
int main()
{
int n, m;
cout << "enter first number";
cin >> n;
    cout<<"enter the second number";
cin >> m;
if (n == m)
{
cout << "n is equal to m";

}
else if (n > m)
{
cout << "n is greater than m";
}
else
{
cout << "n is less than m";
}
return 0;
}
..........................................................................
#include <iostream>
using namespace std;
int main()
{
int a, b=10;
for (a =0;a=b;a++)
{
if (a = b)
{
cout << "a=b";
break;
}
else
{

}
}
return 0;
}
.............................................................................................................
#include <iostream>
using namespace std;
int main()
{
int a, b;
cout << "enter the two numbers" << endl;
cin >> a;
cout << endl;
cin >> b;
while (a >0)
{
if (a ==b)
{
cout << "a is equal to b";
break;
}
else if (a > b)
{
cout << "a is greater than b";
break;
}
else
{
cout << "a is less than b";
break;
}

}
return 0;
}
.......................................................................................................................
#include<iostream>
using namespace std;
int main()
{
int a;
cout << "ENter the number";
cin>> a;
int n = 10;
while (a != n)
{
if (a > n)
{
cout << "Guess a smaller number";
cout << "ENter the number";
cin >> a;

}

else if (a < n)
{
cout << "Guess a larger number";
cout << "ENter the number";
cin >> a;
}
else {
cout << "You have got the number";
break;
}
}
return 0;

}
............................................................................
#include <iostream>
using namespace std;
int main()
{
int array[2];
int size=0;
cin >> size;
array[size];
int sum = 0;
for (int i = 0; i < size; i++)
{
cin >> array[i];
}
for (int i = 0; i < size; i++)
{
sum = sum + array[i];
}
cout << sum;
return 0;
}
...................................................................
#include <iostream>
using namespace std;
int main()
{
int base, exponent,result=1;
cout << "enter the base" << endl;
cin >> base;
cout << "enter expenent" << endl;
cin >> exponent;
for (int i = 1; i <= exponent; i++)
{
result=result*base;
}
cout << result;

return 0;
}
..................................................................................
#include <iostream>
using namespace std;
int main()
{
int A[4] = { 80,15,29,99};
int found = 0;
int b;
cout << "enter the number we want to find";
cin>> b;
for (int i=0;i<4;i++)

if (b == A[i])
{
cout << "number found at" << i;
found = 1;

}

else if(found==0)
{
cout << "number not found";
break;

}
return 0;
}
...........................................................................