TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mohan S
NA
34
39k
Code - Finding GCD of array
Nov 6 2015 4:54 AM
Hi Guys,
I get error with int[] conversion in the below code, please assist.
namespace GCD
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter the number");
int[] input = Convert.ToInt32(Console.ReadLine());
int output = UserProgramCode.GCD(input);
}
class UserProgramCode
{
public static int GCD(int[] array)
{
int a = 0, b = 0, gcd=0, t;
for (int i = 0; i < array.Length - 1; i++)
{
a = array[i];
b = array[i + 1];
while (b != 0)
{
t = b;
b = a % b;
a = t;
}
gcd = a;
}
return gcd;
}
Reply
Answers (
6
)
how to send Email through my Own Domain
Is there any way to generate Power BI visuals from C#?