Consider the following program.
#include <stdio.h>
int do_sth (char *s);
main(){
char arr [] = "We are the World";
printf ("%dn", do_sth(arr));
}
int do_sth(char *s)
{
char *p = s;
while ( *s++ != ‘0’ )
return s - p;
}
What does function do_sth intend to do?
What is the...
consider the following program include ltstdiohgt int dosth char s main char arr we are the world printf dn
dostharr int dosthchar s char p
Written for
EECS 2031
All documents for this subject (1)
Seller
Follow
Themanehoppe
Reviews received
Content preview
Consider the following program.
#include <stdio.h>
int do_sth (char *s);
main(){
char arr [] = "We are the World";
printf ("%d\n", do_sth(arr));
}
int do_sth(char *s)
{
char *p = s;
while ( *s++ != ‘\0’ )
return s - p;
}
What does function do_sth intend to do?
What is the output of the program?
, In the linked list implementations in labtest 2 and lab, to make the code easier, we declare the head to
be a global variable. An alternative way is to declare head as a local variable and pass it as a function
parameter.
Write a function return_type insertFirst(struct node* head, char d) which inserts in
the beginning of the list a new node with data d. You need to define the return type of the function. You
also needs to call this function to insert nodes with data ‘A’and ‘E’ into the list.
#include <stdio.h>
struct node {
char data;
struct node *next;
};
/************* DO NOT ADD MORE GLOBAL VARIABLES *************/
/* call your function (twice) to insert nodes of data ‘A’‘E’ into list */
head = insertFirst (head, ‘A’);
head = insertFirst (head, ‘E’);
}
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller Themanehoppe. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $7.99. You're not tied to anything after your purchase.