Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help my program does not work and I also do not know how to complete the problem. My values keep coming back incorrect.

I need help my program does not work and I also do not know how to complete the problem. My values keep coming back incorrect. For example if I enter batman for hero, and batman for villain it will still say "hero is bigger than villain." I also have no idea how to CONCATENATE them. Please help me out, I typed out the code I have written so far.

--------------------------------------------------------------------------------------------------------------------------------------------------------

image text in transcribed

#define _CRT_SECURE_NO_WARNINGS

#include

#define SIZE 50

#include

int main(void){

//Variable Declaration:

char hero[SIZE] = " ";

char antiHero[SIZE] = " ";

int result;

//Hero:

printf(" Enter the name of your favorite Super Hero: ");

scanf("%s", &hero);

printf("Your hero is %s ", hero);

printf(" Hero length is %d ", strlen(hero));

//Villain:

printf(" Enter the name of your favorite Villain: ");

scanf("%s", &antiHero);

printf("Your villain is %s ", antiHero);

printf(" Villain length is %d ", strlen(antiHero));

// String Comparison

result = strncmp(hero, antiHero, SIZE);

/* If the villain string is bigger */

if (antiHero > hero)

{

printf(" Villain String is more than the Hero ");

}

/* If the Hero string is bigger */

else if (antiHero

{

printf(" Villain string is less than the Hero ");

}

else if(hero == antiHero)

{

printf("Both the Hero and the Villain contain the same string number. ");

}

result = (hero - antiHero);

printf("the value of number is %d", result);

return 0;

}

STRING PROBLEM: Write a C program to ro read in a string from the user and print the string and print the length of the string read in a second string from the user and print the string and print the length of the string . compare the two string and print the output. .concatenate these two strings and print the new string

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_2

Step: 3

blur-text-image_3

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

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

More Books

Students also viewed these Databases questions

Question

What is the role of the chief information officer?

Answered: 1 week ago