Question

I'm having trouble getting my program to output What is your first name? damion what is...

I'm having trouble getting my program to output

What is your first name? damion

what is your last name? anderson

damion, Your first name is 6 characters

Your last name, anderson, is 8 characters

Your name in reverse is:

noimad

nosredna

This is my code so far:

#include <stdlib.h>

#include <stdio.h>

void sizeOfName(char** name);

void printSizeOfName(int *first, int *last, char** name);

void reverseString(int *first, int *last, char** name);

int main() {

  char** name;

  name = (char**)malloc(2*sizeof(char*));

  name[0] = (char*)malloc(100*sizeof(char));

  name[1] = (char*)malloc(100*sizeof(char));

  printf("What is your first name? ");

  scanf("%s",name[0]);

  printf("What is your last name? ");

  scanf("%s",name[1]);

  sizeOfName(name);

  return 0;

}

void sizeOfName(char** name) {

  int firstCount = strlen(name[0]);

  int lastCount = strlen(name[1]);

  printSizeOfName(&firstCount, &lastCount, name);

}


void printSizeOfName(int *firstCount, int *lastCount, char** name) {

  printf("%s, Your first name is %d characters.\n",name[0],*firstCount);

  printf("Your last name, %s is %d characters.\n",name[1],*lastCount);

  printf("\n");

  reverseString(firstCount, lastCount, name);

}


void reverseString(int *first, int *last, char** name) {

  printf("\n\n");

}






0 0
Add a comment Improve this question Transcribed image text
Answer #1

void reverseString(int *first, int *last, char** name) {
  
printf("Your name in reverse is:\n");
  
// Printing the first string in reverse order
for(int i=*first; i>=0; i--)
{
printf("%c",name[0][i]);
}
  printf("\n");
  
// Printing the last string in reverse order
for(int i=*last; i>=0; i--)
{
printf("%c",name[1][i]);
}
  printf("\n");
}

Add a comment
Know the answer?
Add Answer to:
I'm having trouble getting my program to output What is your first name? damion what is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I'm having trouble getting my program to output this statement Enter a sentence: Test! There are...

    I'm having trouble getting my program to output this statement Enter a sentence: Test! There are 5 total characters. There are 1 vowel. There are 1 UPPERCASE letters. There are 3 lowercase letters. There are 1 other characters. Here's my code: #include<string.h> #include<stdio.h> #include<stdbool.h> int main() { char str[100]; int i; int vowels=0; int UC; int LC; int Others; int c; printf("Enter a sentence: \n"); gets(s); LC=countLC(&s); UC=countUC(&s); Others=countOthers(&s); printf("There are %d total characters.\n", ; for(i=0; i<strlen(str); i++){ if(isVowel(str[i])) vowels++;...

  • I'm having trouble getting a certain output with my program Here's my output: Please input a...

    I'm having trouble getting a certain output with my program Here's my output: Please input a value in Roman numeral or EXIT or quit: MM MM = 2000 Please input a value in Roman numeral or EXIT or quit: mxvi Illegal Characters. Please input a value in Roman numeral or EXIT or quit: MXVI MXVI = 969 Please input a value in Roman numeral or EXIT or quit: EXIT Illegal Characters. Here's my desired output: Please input a value in...

  • C program help #include #include #include void PrintName(char firstname[16], char lastname[16]); int main () { char...

    C program help #include #include #include void PrintName(char firstname[16], char lastname[16]); int main () { char firstname[16]; char lastname[16]; printf("please enter your first name:"); scanf("%s",firstname); printf("please enter your last name:"); scanf("%s",lastname); PrintName(firstname,lastname); return 0; } void PrintName(char firstname[16], char lastname[16]){ char fullname[34]; *fullname=*firstname+*lastname; (char*) malloc (sizeof (*fullname)); if (strlen(firstname) > 16||strlen(lastname)>16||strlen(fullname)>16) fflush(stdin); else printf(" the full name is %s %s \n",firstname,lastname); printf(" the full name is-> %s",fullname);/*why is one not run*/ return 0; }

  • Q.25. Given the following program, you are asked to discuss memory leaks caused in its execution....

    Q.25. Given the following program, you are asked to discuss memory leaks caused in its execution. Determine which memory locations get uncontrolled. (2 points) 4 6 7 8 9 10 11 12 B 13 14 15 16 17 18 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 5 void main() { char *aString = "Memory leaks?"; char **strList; int i, n = 5; strlist = (char**)malloc(n*sizeof(char*)); for (i=0; i<n; i++) { printf("\nstring %d ", i+1); strList[i] = (char*)malloc(50*sizeof (char));...

  • Need help, i can't get a infinite loop to work, that terminates when a blank line...

    Need help, i can't get a infinite loop to work, that terminates when a blank line is inputted for the firstName. note: C programing langauge and using microsoft visual studios . #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <math.h> #include <stdbool.h> int main() {    //int arraySalaries[50];    int calculate_avg = 0;    //int calculate_max;    //int calculate_min;    int salary[50];    //int length;    //int average_salary;    char firstName[50][50];    char lastName[50][50];    int i...

  • Create a UNIX makefile for the following C program: //convert.c char toUpper(char c){ if(c>='a' && c<='z')...

    Create a UNIX makefile for the following C program: //convert.c char toUpper(char c){ if(c>='a' && c<='z') return c-32; return c; } //converting sentance to upper void convertSentence(char *sentence){ int i=0; while(sentence[i]!='\0'){ //convert to upper for each character sentence[i] = toUpper(sentence[i]); i++; } } //converting all sentences into uppercase void convertAll(char **sentenceList, int numOfSentences){ int i=0; while(i<numOfSentences){ //calling convertsentence function to conver uppercase convertSentence(sentenceList[i]); i++; } } sentences.c #include<stdio.h> #include<stdlib.h> #include "convert.c" int main(){ //declaring character array char **mySentences; int noOfSentences;...

  • I'm having trouble getting my program to print shapes For example: Which shape (L-line, T-triangle, R-rectangle):...

    I'm having trouble getting my program to print shapes For example: Which shape (L-line, T-triangle, R-rectangle): L Enter an integer length between 1 and 25: 13 ************* Which shape (L-line, T-triangle, R-rectangle): t Enter an integer base length between 3 and 25: 5 * ** *** **** ***** Which shape (L-line, T-triangle, R-rectangle): r Enter an integer width and height between 2 and 25: 4 5 **** **** **** **** **** Here's my code: #include <stdio.h> #include <ctype.h> const int...

  • Could someone please help me with this C language code I'm confused as to why i'm...

    Could someone please help me with this C language code I'm confused as to why i'm getting an error every time I run it on command line if some could please help me as soon as possible. #include <stdio.h> #include <stdlib.h> int main() { char *ptr_two = (char *)malloc(sizeof(char)*50); printf("%p\n", ptr_two); ptr_two = "A constant string in C"; printf("%p\n", ptr_two); printf("%s\n", ptr_two); free(ptr_two); return 0; }

  • I'm having trouble rounding the numbers i'm getting in my output here's my code: #include<stdio.h> int...

    I'm having trouble rounding the numbers i'm getting in my output here's my code: #include<stdio.h> int main() { char gender; float a1, a2, a3, a4, a5; float waistmeasurement, wristmeasurement, hipmeasurement, forarmmeasurement; float B, bodyweight, Bodyfat, Bodyfatpercentage;    printf("This program determines the body fat of a person.Enter your gender (f|F|m|M): "); scanf("%c", &gender); printf("\n");    if(gender=='F' || gender=='f'){ printf("Enter body weight (in pounds): \n"); scanf("%f", &bodyweight); printf("Enter wrist measurement at fullest point (in inches): \n"); scanf("%f", &wristmeasurement); printf("Enter waist measurement at...

  • Convert this C program to Js (Java script) from Visual Studio Code #include<stdio.h> int main(){ char...

    Convert this C program to Js (Java script) from Visual Studio Code #include<stdio.h> int main(){ char firstName[100]; char lastName[100]; printf("Enter Your Full Name: \n"); scanf("%s %s", firstName, lastName); printf("First Name: %s\n", firstName); printf("Last Name: %s\n", lastName); return 0; }

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT