The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 3 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
1)Use function GetUserInfo to get a user's information. If user enters 20 and Holly, sample program output is:
Holly is 20 years old.
#include <stdio.h>
#include <string.h>
void GetUserInfo(int* userAge, char userName[]) {
  printf("Enter your age: \n");
  scanf("%d", userAge);
  printf("Enter your name: \n");
  scanf("%s", userName);
  return;
}
int main(void) {
  int userAge = 0;
  char userName[30] = "";
  /* Your solution goes here */
  printf("%s is %d years old.\n", userName, userAge);
  return 0;
}
2)Complete the function to replace any period by an exclamation point. Ex: "Hello. I'm Miley. Nice to meet you." becomes:
"Hello! I'm Miley! Nice to meet you!"
#include <stdio.h>
#include <string.h>
void MakeSentenceExcited(char* sentenceText) {
  /* Your solution goes here */
}
int main(void) {
  const int TEST_STR_SIZE = 50;
  char testStr[TEST_STR_SIZE];
  strcpy(testStr, "Hello. I'm Miley. Nice to meet you.");
  MakeSentenceExcited(testStr);
  printf("%s", testStr);
  return 0;
}
3)
Write a function SwapArrayEnds() that swaps the first and last elements of its array parameter. Ex: sortArray = {10, 20, 30, 40}
becomes {40, 20, 30, 10}. The array's size may differ from 4
#include <stdio.h>
/* Your solution goes here */
int main(void) {
  const int SORT_ARR_SIZE = 4;
  int sortArray[SORT_ARR_SIZE];
  int i = 0;
  sortArray[0] = 10;
  sortArray[1] = 20;
  sortArray[2] = 30;
  sortArray[3] = 40;
  SwapArrayEnds(sortArray, SORT_ARR_SIZE);
  for (i = 0; i < SORT_ARR_SIZE; ++i) {
     printf("%d ", sortArray[i]);
  }
  printf("\n");
  return 0;
}
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll