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

Is it necessary to learn data structures in C language only?
data structure helpful to improve your coding stability
Vikas
0 0
7
Give the structure of 'C' programming. Also, give significance of math.h and string.h header files.
Hi, C structure is procedural programming. math.h and string .h will have a declerations of predefined methods. math.h ex: sqrt(),...etc. string.h ex: strlen(),strcpy,...etc. if you wanna brif let meknow. Thanks.
Ishwari
Which book is good for C language?
Let Us C by writer-- Yashavant P. Kanetkar (Author)
Rajendra
How do I send a C program via email?
By using Google drive
Furqankhan
0 0
5

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

Ask a Question

Related Lessons

Compiler vs Interpreter
Compiler Interpreter Convert all the code into binary format and execute. Convert one statement at a time and execute, then Convert next statement and execute. After conversion, source...

Set 0 To Kth Bit In A Variable
The following code snippet Set 0 to Kth Bit in an variable #include int UnsetBitValue(int n, int k);int main(){ printf("%d\n\n",UnsetBitValue(255,6)); return 0;}// Set kth bit to zeroint UnsetBitValue(int...

Recursion in C Programming
The process of calling a function by itself is called recursion and the function which calls itself is called recursive function. Syntax of Recursive Function returntype recursive_func () { statements; ...
R

Ravindra Yadav

2 0
0

Everything about printf in C language
What is printf and from where it comes from in C code.? You must have used printf so many times in your Car programs but do you really know everything about printf? Let's see. What is the full form...

INTRODUCTION TO PROGRAMMING LANGUAGES
Language is a medium for communication. If we want to perform anything with another person, we can know the human language as a human being. Similarly, if we want to perform anything with a computer, we...

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