0
I have a problem in the code of an activity of the Analysis course.
The structure of my code is this:
#include <stdio.h>
#include <stdlib.h>
int main(){
int num,menu, i,result, primo;
do{
printf("Menu de Atividades");
printf("Digite 1 para verificar numeros primos\nDigite 2 para verificar o cubo do numero desejado");
switch(menu)
case 1:
printf("Digite um numero para verificar se e primo: ");
scanf("%i",&num);
primo = 0;
for(i=1; i<=num; i++)
if((num%i)==0)
primo++;
if(primo>2)
printf("%d nao e primo\n", num);
else
printf("%d e primo\n", num);
break;
case 2:
printf("Digite um numero: \n");
scanf("%i", &num);
result = num*num*num;
printf("O cubo de %i eh %i", num, result);
break;
default:
break;
}while(menu !=0)
}
I am trying to make a menu to put 2 activities here, the first is to receive a number and return whether or not it is prime, the second is simply receive the number and return the cube.
I managed to do the activities, but I’m having a hard time finishing this menu, because I’m not finding my mistake, and even searching on google I could not solve.
The program I use is Dev C++ and it is returning that has some fault in Switch
that I couldn’t locate.
Really this was one of the problems kkkk, thanks for the warning, I had completely forgotten. But I found some more problems here like the scanf that I had not put to receive value before opening the switch. But thank you.
– João