Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a MIPS program to do the followings: read a string from a keyboard (25%) use a character array count the number of characters in

Write a MIPS program to do the followings:

read a string from a keyboard (25%)

use a character array

count the number of characters in the string (25%)

use loop

reverse the string and print the reversed string(50%)

use loop and a temp character array for reversing

 
main() { 
 char input[1024]; 
 char temp[1024]; 
 int i, str_length = 0; 
 scanf("%s", input); 
 while( input[i] != '\0' ){ 
 i++; 
 } 
 str_length = i; 
 for(i=0; str_length >= 1; str_length--){ 
 temp[i] = input[str_length - 1]; 
 i++; 
 } 
 temp[i] = '\0'; 
 printf("Original string is %s ", input); 
 printf("Reversed string is %s", temp); 
} 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

Students also viewed these Databases questions

Question

Describe the appropriate use of supplementary parts of a letter.

Answered: 1 week ago