Ich bin ein Anfänger zu C (Lernen von freien Ressourcen), ich versuche, einen einfachen Code zu schreiben, um eine Reihe von Zahlen von einem Benutzer eingegeben in eine Reihe von Arrays .... Was mache ich falsch?Wie schreibe ich einen Code, mit dem ein Benutzer verschiedene Werte in Arrays eingeben kann
int numbers;
int number=1;
int counter = 0;
int pot[100];
int calculate;
int result;
printf("how many numbers do you want to calculate?:"); //asking user how many different integers would be calculated
scanf("%d",&numbers);
while (counter < numbers)
{
printf("input number %d\n", number);//asking user to input figures to be calculated
scanf("%d",&pot[0]+1); //user would input values into spaces in the array
counter++;
number++;
}
printf("Please press 1 for addition and 2 for multiplication");
scanf("%d",&calculate);
switch (calculate)
{
case 1: result = pot[0]+ pot[0]+1;//this is supposed to add all the individual values within the arrays
printf("the result is %d", result);
break;
case 2: result = pot[0]* pot[0]+1;//this is supposed to multiply all the individual values within the arrays
break;
}
return 0;
Was ist die Eingabe, die erwartete Ausgabe und die tatsächliche Ausgabe? – dbush
Was ist '& pot [0] + 1'? – stackptr
Entschuldigung, ich verstehe die Frage nicht (Anfängerprobleme)! –