Click here to Skip to main content
12,394,975 members (79,456 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace function_of_product
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("x=");
            Console.Write("y=");
            int x = int.Parse(Console.ReadLine());
            int y = int.Parse(Console.ReadLine());
            int tot = multi(x, y);
            Console.WriteLine("tot=" + res);
            Console.ReadKey();
        }
        static int multi(int x, int y);
 
        int res = x * y;
        Return (res);
 

    }
}
Posted 31-Jan-13 4:55am
Comments
Marcus Kramer 31-Jan-13 11:04am
   
This is clearly either an interview or exam question.
ẶȠǻ ŶắŚmiŋắ 31-Jan-13 15:34pm
   
there any wrong in this statement int res = x * y;
Return (res);

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You are doing

Console.WriteLine("tot=" + res);

I think the res in the above statement should be tot

before

int res = x * y;

There is a lot wrong with your code,

Console.Write("x=");
Console.Write("y=");
int x = int.Parse(Console.ReadLine());
int y = int.Parse(Console.ReadLine());

should be

Console.Write("x=");
int x = int.Parse(Console.ReadLine());
 
Console.Write("y=");
int y = int.Parse(Console.ReadLine());
  Permalink  
v2
Comments
Adam R Harris 31-Jan-13 16:20pm
   
i wonder what this is supposed to do:
static int multi(int x, int y);
DinoRondelly 31-Jan-13 16:22pm
   
static int multi(int x, int y)
{
int res = x * y;
return (res);
}
Adam R Harris 31-Jan-13 16:23pm
   
missing a few curlys i take it then.
DinoRondelly 31-Jan-13 16:24pm
   
I was just trying to help the guy out didnt know i was setting myself up for all this :)
Adam R Harris 31-Jan-13 16:26pm
   
Buddy is either applying for a job and they want him to determine whats wrong with this code OR he is working on something in school and this is one of the problems. What he really should have done is drop it into a new console app and then watch visual studio freak out over all the syntax stuff then tried to run it to work out the logical stuff.
DinoRondelly 31-Jan-13 16:29pm
   
Agreed,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 31 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100