Click here to Skip to main content
Rate this: bad
good
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 at 31-Jan-13 11:04am
   
This is clearly either an interview or exam question.
ẶȠǻ ŶắŚmiŋắ at 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 at 31-Jan-13 16:20pm
   
i wonder what this is supposed to do:
static int multi(int x, int y);
DinoRondelly at 31-Jan-13 16:22pm
   
static int multi(int x, int y)
{
int res = x * y;
return (res);
}
Adam R Harris at 31-Jan-13 16:23pm
   
missing a few curlys i take it then.
DinoRondelly at 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 at 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 at 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
0 OriginalGriff 389
1 Maciej Los 180
2 Richard MacCutchan 140
3 DamithSL 129
4 Kornfeld Eliyahu Peter 119


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