# include<stdio.h> int n_i = 0, n_d = 0; in int no_i[984]; double no_d[984]; voi
ID: 3726906 • Letter: #
Question
#include<stdio.h>
int n_i = 0, n_d = 0;
in int no_i[984];
double no_d[984];
void printValues();
int main()
{
int choice, I, j, temp;
do{
printf(“1)Print author info 2)Print values 3)Clear data 4)Sort data 5)Enter integer 6)Enter double 7)Exit ”);
scanf(“%d”, &choice);
switch(choice)
{
case(1):
printf("Name: ___ ID:_____");
break;
case (2):
printValues ();
break;
case (3):
memset(no_i, 0, sizeof(no_i));
memset(no_d, 0, sizeof(no_d));
i=0;
d=0;
printf(" Data cleared ");
break;
case 4:
for (i = 0; i < n_i; i++)
{
for (j = 0; j < (n_i - i - 1); j++)
{
if (no_i[j] > no_i[j + 1])
{
temp = no_i[j];
no_i[j] = no_i[j + 1];
no_i[j + 1] = temp;
}
}
}
for (i = 0; i < n_d; i++)
{
for (j = 0; j < (n_d - i - 1); j++)
{
if (no_d[j] > no_d[j + 1])
{
temp_i = no_d[j];
no_d[j] = no_d[j + 1];
no_d[j + 1] = temp_i;
}
}
}
printValues ();
break;
case 5: /* Enter integer */
printf(" Enter integer : ");
scanf("%d", &no_i[n_i]);
n_i++;
break;
case 6: /* Enter double */
printf(" Enter double : ");
scanf("%lf", &no_d[n_d]);
n_d++;
break;
case 7:
break;
default: printf("wrong choice.Enter Again");
break;
}
} while(choice != 7);
}
void printValues () {
int i;
printf(" Integer Values :: ");
for(i=0; i<n_i; i++)
{
printf("%d ", no_i[i]);
}
printf(" Double Values :: ");
for(i=0; i<n_d; i++)
{
printf("%lf ", no_d[i]);
}
}
what does these means
“ temp , memset , and can we use some thing diffrent than no_i , no_d
because we don’t use it in class
also about void print values we dont use it in class “
Present a nenu with the following opttons 1) print author infe 2) print valuers ) Clear data 1) Sort data 5) Enter Integer 6) Enter double o) Extt Author info prints your nane .nd Clear data deletes all entered data Sort data sorts both the Integers and the double valurs Enter integer allows the user to enter an Integer value that wilt be stered Enter double allows the user te specify a deuble (or fleat if you choose) value te be stared print data prints out all stored data donot M. t. "sar" that they user dm-t-ow tie limt. Your progran needs to be able to support up to 984 values o, each type,Explanation / Answer
Solution:
temp is just a temporary variable which is used to sort the values which are entered, although case 4 in your code is not asking about values to sort.
It is just the logic to sort an array
memset Sets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted as an unsigned char).
since print function won't return anything that is why void is used here.
void is used for the method when the method doesn't return anything.
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.