Pages

Write a Program to print numbers in squire but with a rectangle

Wednesday 26 March 2014




#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    int i, j=1,k, max_val, count=0, max, fl = 0;
    cout << "Enter Maximum Number: ";
    cin >> max_val;
    cout << endl;
    max = max_val;
for(k=1; k<=max_val; k++)
{
    i = 1;
    count = 0;
    while(i)
    {
           if(i < max_val && count == 0)
           {
                if(i < max)
                {
                    cout << i << " ";
                }
                i++;
           }
           else if(i == max_val)
           {
                count = 1;
                i--;
             if(fl == 1)
             {
                if(max == max_val)
                {
                    max--;
                    cout << "  ";
                }
                else
                {
                    for(j=1; j<= max_val-max; j++)
                    {
                         cout << "    ";
                    }
                    cout << "  ";
                    max--;
                }
             }
             else
                 cout << max_val << " ";
           }
           else if(count == 1)
           {
                if(i-1 < max)
                {
                    cout << i << " ";
                }
                i--;
           }
           else if(i == 0)
                break;
    }
    cout << endl;
    fl = 1;
    
}
    cout << endl;
    system("pause");

}

Write a program in C language that replace spaces by another character or remove spaces

Sunday 23 March 2014

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    char arr[500];
    int ch, count = 0;
    while(ch != 13)
    {
           ch = arr[count] = getche();
           if(ch == 32)
           {
               arr[count] = '-'; //space is replaced by -
           }
           count++;
    }
    cout << endl;
    for(int i = 0; i<= count-1; i++)
    {
         cout << arr[i];
    }
    cout << endl;
    system("pause");
}

How to make diamond in C++. Size of diamond is depend upon user ??

Thursday 13 March 2014

How to make diamond in C++. Size of diamond is depend upon user ??

#include<iostream>
#include<conio.h>
using namespace std;
main()

{
int size;
cout<<"how large u want.. ";
cin>>size;
for(int i=1;i<=size;i++)
{for(int j=size;j>=i;j--)
cout<<" ";
for(int j=1;j<=i;j++)
cout<<"* ";
cout<<"\n";}

for( int i=size;i>=1;i--)
{for( int j=size;j>=i;j--)
cout<<" ";
for(int j=1;j<=i;j++)
cout<<"* ";
cout<<"\n";}

getch();

}

Write a program which takes input in Cartesian coordinates (x, y) and calculate and display the Polar coordinates.

Wednesday 12 March 2014

Write a program which takes input in Cartesian coordinates (x, y) and calculate and display the Polar  coordinates.

#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    float r, thet = 0, rad, x, y;
    cout << "Enter value of x-axis: ";
    cin>>x;
    cout << "Enter value of y-axis: ";
    cin>>y;
    r = (x*x) + (y*y);
    r = sqrt(r);
    thet = atan2(x,y) * 180 / 3.1415;
    cout << endl << "Coordinates in Polar is (" << r << " , " << thet << ")" << endl;
    system("pause");
}

 

Search Box

Most Reading

Contact Form

Name

Email *

Message *