adspace


program for straight line(y=mx+c)

Answer Posted / Tarakeshwar Kumar Puri

[C# code example:]

using System;

public class StraightLine {
public static void Main() {
double m, c, x, y;

Console.Write("Enter slope (m): ");
m = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter y-intercept (c): ");
c = Convert.ToDouble(Console.ReadLine());

Console.Write("Enter a value for x: ");
x = Convert.ToDouble(Console.ReadLine());

y = m * x + c;
Console.WriteLine($"The equation of the straight line is y={y}");
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

No New Questions to Answer in this Category !!    You can

Post New Questions

Answer Questions in Different Category