Since we str < end, this never happens in the above code, so we're okay.

would you please tell me how to check wheather the string is palindrome or not using for loop

Small, but something to keep in the back of your mind.

678123049write a c program , which will give o/p as 678394012and generalize to for higher order matrix.

Assuming you actually want user input to break out of your program rather than using Ctrl-C, you could do something like this:

Update: mmw brings up a good point, which is you do have to be slightly careful how you invoke this, as it does operate in-place.

Qoute of the post : “That’s what’s cool about working with computers.  They don’t argue, they remember everything, and they don’t drink all your beer.” – Paul Leary

Q: write a program to print following output from given inputinput: aaa bbb ccc ddd eee fff ggg hhh iii jjjoutput: bbb aaa ddd ccc fff eee hhh ggg jjj iii..Plz give me answer of this

i want C program using string to display Input:KUMAROutput: K1U2M3A4R5... anyone plz ...

Help me to solve this.....Declare and write a function that changes the value of the passed in argument, so that the caller of the function gets the changes from outside.

std::reverse is a general purpose routine, so I would suggest that you explore different ways to reach that goal.

There's a bunch of C to explore. Have fun with it!

While we're on the subject, you should know what xor (^) means. It's a basic arithmetic operation - like addition, subtraction, multiplication, division, except it's not usually taught in elementary school. It combines two integers bit by bit - like addition, but we don't care about the carry-overs. 1^1 = 0, 1^0 = 1, 0^1 = 1, 0^0 = 0.

While you are starting you should eliminate as much bad practice as possible.

I would move string input down next to where it is used in getline(...):

std::string is defined in the string header. Not every compiler includes string with iostream or algorithm (VS doesn't), so you have to include it explicitly. Don't rely on automatic includes.

how to create a c program of mirror number 5? please help me. not reverse .but mirror.

This complete program shows how I would do it. Keep in mind I was writing C when most of you whippersnappers were a glint in your mothers eyes so it's old-school, do-the-job, long-var-names-are-for-wimps. Fix that if you wish, I'm more interested in the correctness of the code.

You can put your (len/2) test in the for loop:

But it is explained through comments. I thought it was more than enough.

In addition to what others said, your program is running now because iostream happens to have an #include <string> in it but this is not required. It's good practice to include what you're using so you know the program will work in any case, in addition to your 2 includes you should add

Also, this may be picky, but len/2 should be calculated only one time, IMO.

Things like running == true are completely unnecessary, as running is already a condition in itself. Just use running.

We can do simple arithmetic with pointers. When we increment (or decrement) a pointer, we simply move it to refer to the next (or previous) memory location for that type of value. Incrementing pointers of different types may move the pointer by a different number of bytes because different values have different byte sizes in C.

It handles NULLs, empty strings and all string sizes. I haven't tested it with strings of maximum size (max(size_t)) but it should work, and if you're handling strings that big, you're insane anyway :-)

Just a rearrangement, and safety check. I also removed your non-used return type. I think this is a safe and clean as it gets:

This solution is based on GManNickG's post with a few modifications. The initial logical statement may be dangerous if !str is not evaluated before the strlen operation (For a NULL ptr). This wasn't the case with my compiler. I thought I would add this code because its a nice example of a do-while loop.

Simple string reverse program in C

So the values are swapped. This does have one bug - when a and b are the same variable:

If you want to practice advanced features of C, how about pointers? We can toss in macros and xor-swap for fun too!

Will cause your code to flame and die at runtime. That's because string_literal merely points to the string that is stored as part of your executable - which is normally memory that you are not allowed to edit by the OS. In a happier world, your compiler would know this, and cough an error when you tried to compile, telling you that string_literal needs to be of type char const * since you can't modify the contents. However, this is not the world my compiler lives in.

So why name them? You can just omit the names, or define a main which takes no parameters:

I won't repeat what's been said about your basics, but rather have implemented them in this example.

I don't see a return statement, and you are changing the input string, which may be a problem for the programmer. You may want the input string to be immutable.

As we know String is charracter array and Character array have character range between 0 to length-1. Thus we have position of last character in variable ‘j’.Current Values of ‘i’ and ‘j’ are –

write a program to print the following pattern using 1 loop(i.e. u can use a loop only once any loop)2 4 6 8 101 3 5 7 9

Write a C program that take input 5 diferent student from user and save them in file using standard io by arranging them in ascending order by name while each record contain student's name seat no obtained marks and percentage

write a program if a customer has an account more than 5 years and is a government servant then loan approve , government servant or not an account more than 5 years loan approve , customer account less than 5 years and not a government servant then loan not approve.

This is an Assignment Question from morpheus TMF1414 Sem1 2015/2016

Anyone help me!!!Given a list of space separated words, reverse the order of the words.Input :this is a testfoobarall your baseOutput:Case #1: test a is thisCase #2: foobarCase #3: base your all

Create a 1-D 25-elements character array named myString.o Ask the user to input a string and store it in the array.o Pass the string to a function named reverse, which prints the string in reverse order (withoutusing a temporary variable or using another array).