Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C Strings declarations Show a declaration of a C string array variable large eno

ID: 3767100 • Letter: C

Question

C Strings declarations Show a declaration of a C string array variable large enough to contain your first (personal) name. Be sure to include room for the NULL terminating character. The array variable should be initialized to contain your first name. Show an internal representation of your first name. For example, to show the internal representation of "x=" on the answer sheet, one would type: C String Comparisons For each of the following C string comparisons, tell whether strcmp() returns 0, a value less than 0 (a negative value), or a value greater than 0 (a positive value)? strcmp("158", "435") strcmp("abc", "ABC") strcmp("Jim", ".Timmy") strcmp("Brenda", "Brenda")

Explanation / Answer

the fullname array contains the name(first name) as well as the lastname together so that is why it is big enough and twice the size of both name and lastname.

we can implement this using by the following program:

if name is ALEX HAL

IT WILL BE REPRESENTED AS:

0        1              2            3          4              5           6           7              8            

A          L             E            X                           H          A           L             /0(NULL)

1. strcmp("158"," 435") will return negative value as 158<435

2. strcmp("abc","ABC") will return positive value as ( abc>ABC in the ASCII TABLE)

3.strcmp("jim","jimmy") will return negative value as jim < jimmy(ascii)

4.strcmp("Brenda","Brenda") will return 0 as they both are equal.

hint :http://www.asciitable.com/