Click here to Skip to main content
Sign Up to vote bad
good
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:55

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

1 solution

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  
Comments
Adam R Harris - 31 Jan '13 - 16:20
i wonder what this is supposed to do: static int multi(int x, int y);
DinoRondelly - 31 Jan '13 - 16:22
static int multi(int x, int y) { int res = x * y; return (res); }
Adam R Harris - 31 Jan '13 - 16:23
missing a few curlys i take it then.
DinoRondelly - 31 Jan '13 - 16:24
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:26
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:29
Agreed,

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 508
1 Arun Vasu 315
2 Maciej Los 218
3 OriginalGriff 205
4 Aarti Meswania 170
0 Sergey Alexandrovich Kryukov 9,670
1 OriginalGriff 7,409
2 CPallini 3,968
3 Rohan Leuva 3,352
4 Maciej Los 2,861


Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 31 Jan 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid