• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Can anyone solve this question in C programming Language?

jeena1

Banned
Hi...

Write code to solve the following problem. Define a function that takes a String as a parameter and returns an integer value. The function need to loop through each character in the input string to find a value of ?x?. If a value of ?x? is found in the string then return the position within the string where ?x? is found else return -1.

_____________________

http://www.embroideryplanet.co.uk/
http://www.seo-services-seo.co.cc/


--------------------------------------------
Solution that was posted below has been removed.

Homework assistance is allowed here - doing others work is not allowed.

Senior Anandtech Moderator
Common Courtesy


I'm going to go ahead and lock this up. It's just too blatantly an attempt to get homework done, and I don't see any value in leaving it open (i.e. it's not going anywhere else good). OP, if you want help with this problem, then give it a try yourself and if you have trouble post those specific questions in another thread.

Programming Moderator
Markbnj

 
Dude, you weren't supposed to just do it for him (as this is a obviously a homework question). Seriously, the c code is almost completely described in the problem definition. You need to work out how to do this on your own.
 
Psst. Keep it down. Keeping new programmers from learning how to think reduces marketplace competition, and it's a down economy 😛
 
It sometimes helps to describe a problem like this in comments before you start coding. In fact, I'll do the first step for you:

// Define a function that takes a String as a parameter and returns an integer value.
// The function need to loop through each character in the input string to find a value of ?x?.
// If a value of ?x? is found in the string then return the position within the string where ?x? is found else return -1.

Step 2 is to make sure the solution is spelled out well enough for you to write code for it. Here I think it is, but you might disagree. If it's not spelled out well enough for you, add more comments until it makes sense.

Step 3 is to write the code under each comment that is described by that comment.

If you do these steps, you wind up with a good solution that is also well-commented. 🙂
 
Back
Top