UrbanPro

Learn C Language from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

How do I write code in C programming that will invert a string like "Welcome to programming" to “gnimmargorp ot emocleW”?

Asked by Last Modified  

Follow 13
Answer

Please enter your answer

void main() { char msg = "Welcome to Programming"; char str; int i = 0, j = 0; clrscr(); while (msg != '\0') { if (msg != ' ') { str = msg; j++; } else { str = '\0'; printf("%s", strrev(str)); printf(" "); ...
read more
void main() { char msg[] = "Welcome to Programming"; char str[10]; int i = 0, j = 0; clrscr(); while (msg[i] != '\0') { if (msg[i] != ' ') { str[j] = msg[i]; j++; } else { str[j] = '\0'; printf("%s", strrev(str)); printf(" "); j = 0; } i++; } str[j] = '\0'; printf("%s", strrev(str)); getch(); } read less
Comments

Trainer

You can use recursion to reverse a string.
Comments

Tutor

First, find the position of \0 in the string, and it will be the size of the string. Now run a for loop from (size-1) to 0 and copy the char at the index in a temp array of chars. That's it
Comments

Online Computer Trainer

#include"stdio.h" #include"string.h" int main() { char *str = "Welcome to programming"; int i,j,len,temp; len=strlen(str); for(i=0,j=len-1;i
Comments

Working as a Data Scientist in Bangalore, India

//Jaspreet Singh. Contact Detail:- 798633671.8 #include stdio.h //angular brackets not allowed in this website, you will have to add #include string.h //angular brackets not allowed in this website, you will have to add void reverse(char , int, int); int main() { char str1; int...
read more
//Jaspreet Singh. Contact Detail:- 798633671.8 #include stdio.h //angular brackets not allowed in this website, you will have to add #include string.h //angular brackets not allowed in this website, you will have to add void reverse(char [], int, int); int main() { char str1[20]; int size; printf("Enter a string to reverse: "); scanf("%s", str1); size = strlen(str1); reverse(str1, 0, size - 1); printf("The string after reversing is: %s\n", str1); return 0; } //Jaspreet Singh. Contact Detail:- 798633671.8 void reverse(char str1[], int index, int size) { char temp; temp = str1[index]; str1[index] = str1[size - index]; str1[size - index] = temp; if (index == size / 2) { return; } reverse(str1, index + 1, size); } //Jaspreet Singh. Contact Detail:- 798633671.8 read less
Comments

Tutor

void main() { int i, j, k; char str; char rev; printf("Enter a string\t"); scanf("%s", str); printf("The original string is %s\n", str); for(i = 0; str != '\0'; i++); { k = i-1; } for(j = 0; j <= i-1; j++) { rev = str; k--; } printf("The reverse...
read more
void main() { int i, j, k; char str[100]; char rev[100]; printf("Enter a string\t"); scanf("%s", str); printf("The original string is %s\n", str); for(i = 0; str[i] != '\0'; i++); { k = i-1; } for(j = 0; j <= i-1; j++) { rev[j] = str[k]; k--; } printf("The reverse string is %s\n", rev); getch(); } read less
Comments

void main() { char str="Welcome to Programming"; int i,l; clrscr(); l=strlen(str); for(i=0;i=0;i--) { printf("%c",a); } }
Comments

Dissertation Helper

You are having four options to write the program. 1. you can make your own reverse function by use of swap. 2. you can use built in reverse function 3. you can write your own reverse function using strlen() 4. using pointer and array if string is constant string
Comments

CodeGeeks

#include "stdio.h" #include "string.h" int main() { char str="Welcome to programming"; int i=strlen(str); for (; i >= 0; i--) printf("%c", str); printf("\n"); return 0; }
Comments

Tutor

#include"stdio.h" void main() { char str; int i, j, temp, len=0; clrscr(); printf("Enter String "); gets(str); len = strlen(str); for(i=0, j=len-1; i < len/2; i++, j--) { temp = str; str = str; str = temp; } printf("\nReverse string is :\n%s", str); getch(); }
Comments

View 10 more Answers

Related Questions

any one can teach me c++
Yes of course i can give you online classes
Bhuvanesh
How many programs are in the C language?
Here, we have provided 100+ C programming examples in different categories like basic C Programs, Fibonacci series in C, String, Array, Base Conversion, Pattern Printing, Pointers, etc.
Muskan
0 0
6
How is C++ language used nowadays?
C++ is a fast and strongly-typed programming language which makes it an ideal choice for developing operating systems. Mac OS X has large amounts written in C++. Most of the software from Microsoft like...
Arumugam
0 0
5
Why is C still so popular?
C remains popular for several reasons, and its enduring popularity can be attributed to a combination of historical significance, efficiency, and versatility. Here are some key reasons why C is still widely...
A
0 0
6
Which is the best software for working with C language?
Choosing the best software for C programming often depends on personal preference, but popular options include GCC (GNU Compiler Collection), Visual Studio, and CLion. Consider factors like your platform,...
Kiran
0 0
6

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Do You Know How Is Size Of Structure Defined?
Size of the structure is defined based on multiplies of bigger data type member in the structure. Example: If a structure contains integer, char, short data type, then size of the Structure will be multiples...

What Are IT Industries Performance Metrics?
1. Outstanding Expectation: Eligible to get Promotion easily and good salary hike. Always preferrable to go abroad. 2. Exceed Expectation: Can get Promotion as per schedule of company with good salary...

Why C is a Language and not a database?
When I interviewed a candidate, I raised this question many times, but I have not got the answer correctly. To under why C is a language and not a database, it is good to understand why our communication...

Operators in C
Operators in C Operator: An operator is a symbol that tells the compiler to perform certain mathematical or logical calculations. Operators are used in programs to manipulate data and variables. The...

Recommended Articles

Lasya Infotech is a Hyderabad based IT training institute founded in 2016 by O Venkat. Believing in his innovation, passion and persistence and with a diverse blend of experience, he started his brainchild to deliver exemplary professional courses to aspiring candidates by honing their skills. Ever since the institute envisions...

Read full article >

Brilliant Academy is one of the reputed institutes for B.Tech tuition classes. This institute is specialised in delivering quality tuition classes for B.E, Engineering - all streams and Engineering diploma courses. Incorporated in 2012, Brillant Academy is a brainchild of Mr Jagadeesh. The main motto of the academy is to...

Read full article >

Almost all of us, inside the pocket, bag or on the table have a mobile phone, out of which 90% of us have a smartphone. The technology is advancing rapidly. When it comes to mobile phones, people today want much more than just making phone calls and playing games on the go. People now want instant access to all their business...

Read full article >

Whether it was the Internet Era of 90s or the Big Data Era of today, Information Technology (IT) has given birth to several lucrative career options for many. Though there will not be a “significant" increase in demand for IT professionals in 2014 as compared to 2013, a “steady” demand for IT professionals is rest assured...

Read full article >

Looking for C Language Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for C Language Classes?

The best tutors for C Language Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn C Language with the Best Tutors

The best Tutors for C Language Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more