I'm not that good at English, but I'm wondering why my code for loop section is using printf twice instead of only once when scanf stops it? I use for loop just because I like to make it similar to for loop on top of it
#include <stdio.h>
#include <stdlib.h>
float findMax(float * number);
float findMin();
float findSum();
float sortVector();
int main()
{
float number[7];
char choice;
printf("Enter 7 number into the vector: ");
for(int i = 0; i < 7; i++)
{
scanf("%f", &number[i]);
}
for( ; ; )
{
printf("#################### MENU ####################\nA. Find the maximum number in the vector\nB. Find the minimum number in the vector\nC. Find the total of number in the vector\nD. Sort number in the vector in the ascending order\nQ. Quit Program\nEnter your chioce <A, B, C, D or Q> : ");
scanf("%c", &choice);
switch(choice)
{
case 'A':
printf("The total of numbers in the vector is %.2f", findMax(number));
break;
case 'a':
printf("The total of numbers in the vector is %.2f", findMax(number));
break;
case 'B':
break;
case 'b':
break;
case 'C':
break;
case 'c':
break;
case 'D':
break;
case 'd':
break;
case 'Q':
exit(0);
break;
case 'q':
exit(0);
break;
}
}
return 1;
}
float findMax(float * number)
{
float max;
return max;
}
Do I miss something or do I code it wrongly?
P.S. This work is not finished yet and I'm just a beginner at coding.