473,322 Members | 1,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

please do this for me

I got this in a company paper I was solving online...
Can someone explain me what this code should do?and whats the error?
int func (int (*)(int) , int);
int cube(int n)
{
return (n*n*n);
}
int main()
{
prinf("%d" , func(cube , 4));
}
int func(int (*tmp)(int in) , int n)
{
int res , i;
for(i = 1 ; i <= n ; i++)
res += *(tmp)(i);
return res;
}

Mar 11 '07 #1
5 1670
am*********@gmail.com wrote:
I got this in a company paper I was solving online...
Can someone explain me what this code should do?and whats the error?
<snip>

You've not cut and pasted the actual code, (likely since I spotted a
'prinf' instead of printf).

The program as given is broken.

Mar 11 '07 #2

<am*********@gmail.comwrote in message
news:11**********************@h3g2000cwc.googlegro ups.com...
I got this in a company paper I was
solving online...
Can someone explain me what this code
should do?and whats the error?
int func (int (*)(int) , int);
int cube(int n)
{
return (n*n*n);
}
int main()
{
prinf("%d" , func(cube , 4));
No such thing as prinf.
}
int func(int (*tmp)(int in) , int n)
{
int res , i;
for(i = 1 ; i <= n ; i++)
res += *(tmp)(i);
Probably (*tmp)(i);
return res;
}
And the "error" you are probably asking
about is
res in not initialized.
Mar 11 '07 #3
On Mar 11, 9:51 am, "amey1.ka...@gmail.com" <amey1.ka...@gmail.com>
wrote:
I got this in a company paper I was solving online...
Can someone explain me what this code should do?and whats the error?
My company does that kind of thing for job interviews.

Step 1: Get through some online problems.
Step 2: Go through a phone interview.
Step 3: Go to a real interview.

Step 1 is there so we don't waste your time and our time in Step 2.
Cheating is quite pointless, because if you have to cheat in an online
interview, you won't make it through the phone interview anyway.
(First question in the phone interview: What does the first line in
that program do? )

Mar 11 '07 #4
am*********@gmail.com <am*********@gmail.comwrote:
Can someone explain me what this code should do?and whats the error?
Hm, if you can't be bothered to run a compiler to solve an online
quiz, why would anyone assume you could be bothered to be paid to run
one? There are at least 5 errors in the code you posted.

(The code is not complicated. Make another pass through K&R before
you apply for any other jobs.)

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
Mar 12 '07 #5
Barry <ba****@nullhighstream.netwrote:
int func(int (*tmp)(int in) , int n)
{
int res , i;
for(i = 1 ; i <= n ; i++)
res += *(tmp)(i);
Probably (*tmp)(i);
Or tmp(i).
And the "error" you are probably asking
about is
res in not initialized.
I'm a little surprised that I did not receive a warning from gcc about
that subtle mistake.

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
Mar 12 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: KK | last post by:
Hi Peoples, Can anyone give me any learning materials for learning C++. i.e. can you give me any docs or give me the link to any website that has info on programming in general or C++. (ok...
1
by: HolaGoogle | last post by:
Hi all, Please help me with the following..it's realy urgent and i tried everything i could and i can't get it work properly!! Thanks in advance. Here's what i'm trying to accomplish: in my...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
4
by: pshindle | last post by:
DB2 Team - I just downloaded and unzipped the new Fixpack 9 for DB2 ESE V8 for Windows (FP9_WR21350_ESE.exe). I then burned the unzipped Fixpack files to a CD. I proceded to install this...
3
by: Mark Broadbent | last post by:
could somebody please recommend a good book to prepare for exam Exam 70-320*: Developing XML Web Services and Server Components with Microsoft Visual C# and the Microsoft .NET Framework . One that...
9
by: FERHAT AÇICI | last post by:
hi all! who know arrays on visual basic please tell me.... thanks..
31
by: Simply_Red | last post by:
i'm sorry i posted this in other groupes, and i didn't see it, and as this group is most actif, i repost it here, and sorry for mutliposting: Hi, i'm using VC6, i have this declaration: ...
6
by: jenipriya | last post by:
Hi all... its very urgent.. please........i m a beginner in oracle.... Anyone please help me wit dese codes i hv tried... and correct the errors... The table structures i hav Employee (EmpID,...
2
by: Unpopular | last post by:
void directory::modification()//??????????? { clrscr(); cout<< "\n\t @@@@@@ @@@@@ @@@@@ @@@@@@ @@@@@ @ @ @@@@@@ "; cout<< "\n\t=====@ @ @ @ @ @ @@...
4
by: ssniit | last post by:
Please can anyone help me with d programs in C for treat the matter most urgent please please please please .................................! CPU scheduling: WAP to show FCFS scheduling...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.