Click here to Skip to main content
11,578,954 members (64,818 online)
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 Peter Leow 115
1 Frankie-C 115
2 OriginalGriff 113
3 Afzaal Ahmad Zeeshan 85
4 Richard MacCutchan 85
0 OriginalGriff 933
1 Sergey Alexandrovich Kryukov 740
2 Abhinav S 573
3 F-ES Sitecore 420
4 Dave Kreskowiak 419


Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 31 Jan 2013
Copyright © CodeProject, 1999-2015
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