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: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 4 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
What am I doing wrong? I need first to point to the first number in the array, last to point to the number after the last number in the array, and then I need to print the numbers. I keep getting the first to print as 0 and last to print as a bunch of numbers. I know there's an easier way to print numbers in an array, this is just part of the assignment
Â
#include<stdio.h>
int main()
{
  int array[2];
  int first;
  int last;
  int value;
Â
  for(value=0;value<3;value++)
  {
    printf("Enter a number ");
    scanf("%d",(array+value));
  }
  array[0] = first;
  array[2] = (last-1);
Â
  printf("nYou entered: n");
  for(value=0;value<3;value++)
  {
    printf("%dn",*(array+value));
  }
  printf("The first number in the array is %dn", first);
  printf("the number after the last number in the array is %dn", last);
Â
  return 0;
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly