1) Write a program to count the number of blank spaces in a given string.
2) Write a program to abbreviate a given string (e.g. if the input is Amar Akbar Anthony, the output will be AAA)

Recommended Answers

All 6 Replies

Those are neither doubts nor questions. I doubt your intentions are anything but those of a cheater looking for free code to get through assignments without any effort. I also doubt that helping you would be anything but a waste of my time because you'll do one of two things:

  1. Run off with any code that's given to you, never to be seen again.
  2. Bitch and moan about being helpless and stupid if I try to teach you how to write code yourself.

Can you alleviate those doubts? No? Then go cheat somewhere else.

help man without being too aggressive. i am new to this C programming world. if you dont want to help then dont make such comments. you might be a pro in this but i am not.....i am learning...
in future, you also might need some help in something and i hope at that time, if you get the same reply as you said now to me, you will remember me then..

>if you dont want to help then dont make such comments.
I'd love to help you. But I'm not going to waste my time on a lost cause. If you can prove that you're not a lost cause, you'll find me to be an excellent resource. However, posting your assignment without any kind of attempt or specific question strongly suggests that you're yet another lazy cheater (we get a lot of them around here) looking for a free ride.

>in future, you also might need some help in something and i hope at that time,
>if you get the same reply as you said now to me, you will remember me then..

I remember people like you every time I help myself or teach myself something new. Would it interest you to know that I taught myself C through trial and error? I didn't discover all of the wonderful resources on the web until long after I had overcome the difficulties you're experiencing now, so your "I'm just a beginner wah wah wah" defense is falling on deaf ears.

I think this might be a miscommunication issue rather than someone being lazy, although its very possible that Narue is correct. Either way, I am tempted never to judge someone completely based on how they ask for help. The audience of this site seems to be largely non-english speakers and often times they will say less because they are shy with their weak language skills.

May I suggest to abhiab1991 to write some code attempting to do what the questions ask and then post it here for more specific help?

1) Write a program to count the number of blank spaces in a given string.
2) Write a program to abbreviate a given string (e.g. if the input is Amar Akbar Anthony, the output will be AAA)

1. Go through the string, and increment a counter when you encounter a blank space.
2. Go through the string, and store the first letter of each word (let the word be a string of letters between blank spaces) inside an array of characters.

You need to find out how to do the above in C. For this, you need some knowledge of how strings are stored, how to loop through a string (and how to look for the end of a string), and conditional statements. I can give you the highlight for the first program:

#include <stdio.h>

int main(void) {

    /* Declare the variables */

    /* Get the string */

    /* Go through the string */
        /* If you encounter a white space */
            /* Increment the counter */

    return 0;
}

Replace the comments with actual code. Write the comments version for the second task, and then replace the comments with actual code.

thanks everyone
could do both of them

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.