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

How can I write a C program to print a name without using a semicolon?
void main() { switch(printf("My name is john")) { } }
Anand
0 0
6
What is C? Where it is used ?
C has the advantage that it is a relatively small language, which makes it easy to implement a C compiler (whereas a C++ compiler is a monster to write), and makes it easier to learn the language. C...
Chandi
Can one new to programming learn Java, C, or other languages first?
First you can learn C language because it is Mother of all the all advanced language. then we can learn c++,Java,.NET, because all advanced language syntax is inherits from C language. If u r basic is good then u can learn every advanced language.
Agastya
0 0
5

Program to accept a list of elements and find the maximum number in the list. 

 

The logic will be 1. Create an array of the desired type 2. Sort the array in the descending order 3. Fetch the first elemnet from the array, this will be the maximum element in that array. Now use...
Lavanya
0 0
8

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

Ask a Question

Related Lessons

C Program-Temperature [conversion from farenheit to degree celsius]
//WAP to convert temperture from farenheit into degree celsius //Header files#include<stdio.h>#include<conio.h> //Main functrion void main(){ //Variable declaration of type float float...

10 Tips to improve your learning
1. Have a quick revision of topics that you have read in past three days before you start studying a new topic. 2. Make your own notes containing the summary of the topic. 3. Allot proper timing for...

An Interesting discussion about malloc( ) and calloc( )
What are malloc( ) and calloc( )? Simply putting they are the predefined functions in C language. Malloc( ) and calloc( ) are two such functions which are used for more or less identical purpose and...

Efficient Learning Strategies
Type your notes after class Write your notes onto flashcards - Scrabble -Make posters Review flashcards while walking, at gym, etc. Dog-ear pages in the reading where you can find...

Pro learners tip for C language
First get the concept of algorithm before heading to write your first program.

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