Q:

Write a C# Sharp program to display certain values of the function x = y2 + 2y + 1 (using integer numbers for y , ranging from -5 to +5)

0

Write a C# Sharp program to display certain values of the function x = y2 + 2y + 1 (using integer numbers for y , ranging from -5 to +5)

Sample Output:

x = y² - 2y +1                                                                                                 
y = -5 ; x=(-5)² - 2*(-5) +1 = 36                                                                             
y = -4 ; x=(-4)² - 2*(-4) +1 = 25                                                                             
y = -3 ; x=(-3)² - 2*(-3) +1 = 16                                                                             
y = -2 ; x=(-2)² - 2*(-2) +1 = 9                                                                              
y = -1 ; x=(-1)² - 2*(-1) +1 = 4                                                                              
y = 0 ; x=(0)² - 2*(0) +1 = 1                                                                                 
y = 1 ; x=(1)² - 2*(1) +1 = 0                                                                                 
y = 2 ; x=(2)² - 2*(2) +1 = 1                                                                                 
y = 3 ; x=(3)² - 2*(3) +1 = 4                                                                                 
y = 4 ; x=(4)² - 2*(4) +1 = 9                                                                                 
y = 5 ; x=(5)² - 2*(5) +1 = 16

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
public class Exercise6
{
    public static void Main()
    {
        int x, y;
         
        Console.WriteLine("x = y² - 2y +1");
        Console.WriteLine();
         
        for (y=-5; y <= 5; y++)
        {
            x = y*y - 2*y + 1;
            Console.WriteLine(
                "y = {0} ; x=({0})² - 2*({0}) +1 = {1}",
                y, x);
        }
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now