Jump to content

[C] Ajuda: Problema no código (Resolvido)


Recommended Posts

Posted

Olá pessoal... Estava aqui a fazer este programa-exercicio visto que estou a aprender e dá-me o seguinte erro de compilação....

C:\~\Exercs\exerc0410.c In function `main':

Linha:22  C:\\Exercs\exerc0410.c syntax error before "printf"

#include <stdio.h>

main()
{
int num;
char ans='y';
      while (ans=='y') do
      {
      
      do
         {
         printf("Introduza um numero "); scanf("%d",&num);
         if (num>=1 && num<=100) 
             printf("%d esta entre 1 e 100\n",num);
         else
             printf("%d nao esta entre 1 e 100\n",num);
         }     
          while(num<1 || num>100);
          
       }
       
       printf("Quer repetir? (y or n) "); scanf("%c",&ans);
}

Any help? 🙂

Posted

Tens um do a mais

while (ans=='y') do (ESTE)
      {
      
      do

PS: Curti o título do post. "Problema problemático." 🙂

EDIT: O último printf tem de estar antes de fechar a chaveta, entre o ciclo while.

"Nunca discutas com um idiota. Eles arrastam-te até ao seu nível e depois ganham-te em experiência"

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.