I am a CE student and I am still learning the basics
so far I am studying the array on c++ program
I have this question and Unfortunately I have no idea how to slove it!
-------------------------------------------------------------------------------
>> Lab question 9.1.3
All the steps are related. You need to write all the code in just one program file. Declare any new variable when required.
Copy the following piece of code into your Visual C
#include <stdio.h>
#define size 7
void main (void)
{
int List[size]={0};
}
Add a portion of code that would read the values for the array list from the users.
Add a portion of code that would display the values of array list to user.
Add a portion of code that would sum up all the values of array list and print the sum to users.
Add a portion of code that would find and display the least value in the list.
Add a portion of code that would find and display the highest value in the list.
------------------------------------------------------------------------------
The code that I tried to solve is like this :
#include <stdio.h>
#define size 7
void main (void)
{
int list[size]={0};
int i,n,sum;
printf("enter numbers:");
scanf("%d\t",&n);
for(i=n;i<=size;i++)
{
list[size]=n;
printf("%d\n",list[size]=n);
}
}
what do you want to do..???
here user has to enter number (n) which should be <=7, because this loop will run upto i=7 as u earlier declare size =7.
and every time u r putting value at the same index , list[size] i.e list[7]