Bite-Code™

Home » Post Item » Find out the square.

Find out the square.

March 1, 2010

#include<iostream>
using namespace std;

int i,x;
int num[10][2]={
    {1,1},
    {2,4},
    {3,9},
    {4,16},
    {5,25},
    {6,36},
    {7,49},
    {8,64},
    {9,81},
    {10,100}
    };

int main()
    {
        cout<<”Enter a number between 1 and 10: “;
        cin>>i;
            for(x=0; x<10; x++)
                if(num[x][0]==i) break;
         cout<<”The square of “<<i<<” is “<<num[x][1]<<endl;
     return 0;

 

    }

 

 

Posted by mowllen at 10:14 am | permalink

All comments are moderated. Your comments will not appear here unless approved by the blog owner. Thank you.

Add a comment