Thursday, July 17, 2008

yearn online vitout investing

Welcome to A.W.Surveys!

We would like to thank you for being part of A.W.Surveys. With your help we are one of the fastest growing survey companies in the world. We are proud that our Web Site Evaluations are helping change how the web looks. We believe we have the best survey takers in the world, which is why we value and pay so much for your evaluations.

July is Here!! - New Announcements

The $500 Monthly Bonus cash prize for June has ended! The winner for June is MandySa****! Congratulations!

7/1/2008 - The July Bonus Contest starts today. Please remember you receive $1 for completing this survey and will also be entered into our $500 Monthly Contest.

7/8/2008 - As A.W.Surveys continues to grow we are always looking for new ways to improve our services. We are now considering adding AlertPay as our 3rd payment option. Currently we pay members with PayPal or by Check. Further details on this will be available shortly.

7/14/2008 - AlertPay will be added as our 3rd Redeem Payment option later this month. Please remember we are not removing any of our previous payment methods but adding a 3rd payment option for you.

Determination of Prime Factors using Functions.
A positive integer is entered through the keyboard.
Write a function to obtain the prime factors of this number.
For example, prime factors of 24 are 2, 2, 2 and 3, whereas prime factors of 35 are 5 and 7.



#include
main()
{

int number;
int prime(int number);

int primefactor(int number);


printf("Enter the number whose prime factors are to be calculated:");

scanf ("%d", &number);

primefactor(number);

}

//The following function detects a Prime number.

prime(int num)
{
int i, ifprime;


for (i=2; i<=num-1; i++)

{
if (num%i==0)
{

ifprime=0;
}
else
ifprime=1;

}
return (ifprime);
}


//The following function prints the prime factors of a number.

primefactor(int num)
{
int factor,ifprime;
for (factor=2; factor<=num;)

{
prime(factor); //so that the factors are only prime and nothing else.
if (ifprime)

{
if (num%factor==0) //diving by all the prime numbers less than the number itself.
{

printf("%d ", factor);
num=num/factor;

continue;
}
else
{
factor++;//this cannot be made a part of the for loop

}
}
}
return 0;
}





Calculation of A to the power of B using Functions
Write a function power(a,b), to calculate the value of a raised to b.



#include
main()
{

int power (a,b);
int a, b, result;

printf("Enter the value of a and b:");
scanf ("%d %d", &a, &b);

result=power(a,b);
printf("%d raised to %d is %d", a, b, result);

}

power (int a, int b)
{

int calculation=1, calc;
for (calc=1; calc <=b; calc++)

{
calculation=calculation*a;
continue;
}

return(calculation);
}



Conver the given year to Roman Numerals using Functions.
Write a general-purpose function to convert any given year into its roman equivalent.
The following table shows the roman equivalents of decimal numbers:

Decimal:........Roman
1.....................i
5....................v
10..................x
50..................l
100................c
500...............d
1000.............m

Example:
Roman equivalent of 1988 is mdcccclxxxviii
Roman equivalent of 1525 is mdxxv

This program is a big lengthy owing to the use of Case Statements. This program can also be rewritten using Arrays, which will reduce the length considerably.


#include
main()
{

int year;
int convert (int year);



{

printf("Note:Enter a four year digit year.\n\n");

printf("Enter the year that you wanna convert to Roman: " );

scanf ("%d", &year);

if (year> 1999)

{
printf("Invalid Year.Please enter again.\n\n");
}
}

convert(year);


}



convert(int year)

{
int i;

printf("\nYear converted to Roman:");


i=(year/1000); //thousands place
if(i==1)

{
printf("m");
}


i=((year/100)%10); //hundreds place

switch (i)
{
case 1:
printf("c");

break;

case 2:
printf("cc");

break;

case 3:
printf("ccc");

break;

case 4:
printf("cd");

break;

case 5:
printf("d");

break;

case 6:
printf("dc");

break;

case 7:
printf("dcc");

break;

case 8:
printf("dccc");

break;

case 9:
printf("dcccc"); //this part you may think is wrong..9 -> cm

break; //but i have taken a hint from the example in the question.

}



i=((year/10)%10); //tens place

switch(i)
{
case 1:
printf("x");

break;

case 2:
printf("xx");

break;

case 3:
printf("xxx");

break;

case 4:
printf("xl");

break;

case 5:
printf("l");

break;

case 6:
printf("lx");

break;

case 7:
printf("lxx");

break;

case 8:
printf("lxxx");

break;

case 9:
printf("lxxxx"); //had it not been for this example, it would have been xc

break;

}



i=year%10; //ones place

switch(i)
{
case 1:
printf("i");

break;

case 2:
printf("ii");

break;

case 3:
printf("iii");

break;

case 4:
printf("iv");

break;

case 5:
printf("v");

break;

case 6:
printf("vi");

break;

case 7:
printf("vii");

break;

case 8:
printf("viii");

break;

case 9:
printf("ix");

break;
}


printf ("\n\n");

return 0;

}







Detection of Leap year using Functions.
Any year is entered through the keyboard.
Write a function to determine whether the year is a leap year or not.



#include
main()
{

int leap_year(year);
int year, lp;

printf("Enter the year:");
scanf ("%d", &year);

lp=leap_year(year);

if (lp)

{
printf("\nThe entered year is a leap year.");
}
else
{

printf("\nThe entered year is not a leap year.");
}

}


leap_year(int y)

{
int lp;

if (y%4==0)

{
lp=1;
}
else
lp=0;

return(lp);
}
Calculation of Sum, Average and Standard Deviation using Functions and Pointers.
Write a function that receives 5 integers and returns the sum, average and standard
deviation of these numbers. Call this function from main() and print the results in main().



#include
#include

int calc (float a, float b, float c, float d, float e, float *sum, float *avg,float *sd);

int main()
{
float a, b, c, d, e, sum=0.0, avg=0.0;

float sd=0.0;

printf("Enter Five Numbers:");
scanf("%f %f %f %f %f",&a,&b,&c,&d,&e);

calc (a, b, c, d, e, &sum, &avg, &sd);


printf("\nSum=%f", sum);
printf("\nAverage=%f", avg);

printf("\nStandard Deviation=%f\n", sd);


getchar();

return 0;
}

calc (float a, float b, float c, float d, float e, float *sum, float *avg, float *sd)

{
float Calc=0.0;

*sum = a+b+c+d+e;

*avg = *sum / 5.0;

Calc += ( a - *avg) * ( a - *avg);

Calc += ( b - *avg) * ( b - *avg);

Calc += ( c - *avg) * ( c - *avg);
Calc += ( d - *avg) * ( d - *avg);

Calc += ( e - *avg) * ( e - *avg);


*sd = sqrt((double)Calc/5.0);

}


Calculation of Product of Two Numbers using Function - Returns a Float
This program seems to be rather simple. But there's one little thing to be noted in this particular program. The thing is that the function in this program returns a float. The function declaration is usually given outside main..but due to some other standards that I am following, I have prototyed it inside main..but that doesn't cause much of a difference in this simple program.

Write a function which receives a float and an int from main(), finds the product
of these two and returns the product which is printed through main().

#include
main()
{

int i;
float j, prod;
float product (int x, float y);

printf("Enter the i(int) and j(float):");
scanf ("%d %f", &i, &j);

prod = product(i,j);

printf("Product:%f", prod);

}

product (int x, float y)
{

float product;
product = x*y;
return (product);

}




Calculation of Area and Circumference of a Circle using Pointers
The following program is one good example that illustrates how we can return more than one value in a function. The answer is certainly using Pointers. The following program demonstrates the method.

Write a function that calculates both Area and Perimeter/ Circumference of the Circle, whose Radius is
entered through the keyboard.


#include
main()
{

int radius;
float area, perimeter;

printf("\nEnter radius of a circle:");

scanf ("%d", &radius);
areaperi (radius, &area, &perimeter);

printf("Area=%f", area);
printf("\nPerimeter=%f", perimeter);

}


areaperi(int r, float *a, float *p)

{
*a=3.14*r*r;
*p=2*3.14*r;

}



//This Program exhibits the use of Call By Reference.