munin
+ Reply to Thread
Results 1 to 4 of 4

Thread: Can anyone solve this question in C programming Language?

  1. #1
    Join Date
    Apr 2009
    Posts
    1

    Can anyone solve this question in C programming Language?

    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 -*.
    [url=http://www.****-india.co.uk/] **** India [/url]
    [url=http://www.****-india.co.uk/] Indian Tourist **** [/url]
    [url=http://www.****-india.co.uk/] Tourist **** to UK [/url]

  2. #2
    Join Date
    Sep 2006
    Posts
    1,649
    Do your own homework please. It's bad enough that people depend on formal schooling to learn how to program, but it's even worse when they don't even learn the concepts they are supposed to. Normally I wouldn't care if someone wanted homework help. But in the programming world, there are already enough bad programmers writing b***y code.

    Here's some quick pseudocode to show you what you should do:
    [PHP]int GetPosOfString(char[] input) {
    for (int i = 0, i < sizeof(input), i++) {
    if (input[i] = "x")
    return i;
    }
    return -*;
    }[/PHP]
    "Workers of the world unite; you have nothing to lose but your chains." -Karl Marx

  3. #3
    Join Date
    Dec 2008
    Posts
    9
    Quote Originally Posted by helma View Post
    Can someone enligten me on what below program does?
    I understand getchar and putchar.. but what is this program suppose to do?
    I try to put printf on it, but it shows nothing..

    can someone explain to me what this program is suppose to do?
    It is reading something and assigning to c?

    so, if I do, ./a.out filename , will it assign entire filename's content into c?

    #include <stdio.h>

    /* copy input to output; *st version */

    main()
    {
    int c;

    c = getchar();
    while (c != EOF) {
    putchar(c);
    c = getchar();
    }
    }
    -----------------
    [url=http://www.keywordspy.com/keyword-research-tool]Keyword Research[/url]
    [url=http://www.freebeautymakeover.com]Free Plastics Surgery[/url]
    hmm... that's a bit of a strange code there... course than again I dont code...:|

  4. #4
    Join Date
    Mar 2016
    Posts
    5

    can anyone solve this question in c language ?

    hi, i am not a guru in c language, but i think that you are trying to convert character data type to integer data type in that case as much i know i think that it is not going to be happen, because character data type value could not be convert in integer !

    http://graphicriver.net/item/flat-web-font-icons/*2457*66
    Last edited by mynamebilal; 03-18-2016 at 12:37 AM.

+ Reply to Thread

Similar Threads

  1. Replies: 38
    Last Post: 01-05-2017, 06:48 AM
  2. What's the most popular web programming language?
    By slicegan2 in forum Programming
    Replies: 14
    Last Post: 12-23-2010, 03:32 AM
  3. Programming language choice: Java
    By new_rez in forum General discussion
    Replies: 1
    Last Post: 08-06-2008, 04:20 PM
  4. The best programming language - Power
    By deleteX in forum Programming
    Replies: 9
    Last Post: 11-30-2006, 04:40 PM
  5. Programming Language for Writing Drivers?
    By loopers in forum Internet Privacy
    Replies: 2
    Last Post: 01-16-2003, 05:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts