jeudi 17 janvier 2019

If then goto can;t stop

Why after goto awal, I can't input in my scanf ? i want after goto awal , then scanf again. sorry my english is so bad. any suggestion ?

#include<stdio.h>
#include<ctype.h>
#include<conio.h>
#include<windows.h>
#include<unistd.h>
int main()
{
    awal:
    int num=0,o;
    char term='\0';

    printf("\n\t Masukkan jumlah suku yang anda inginkan = ");
    if(scanf("%d%c", &num, &term) != 2 || term != '\n')
    {

        goto awal;
        system("cls");  
    }
    else
    {
        for(o=1; o<=num; o++)
        {
            printf("%*d",20,o);
            if(o % 5 == 0 && o !=num)
            {
                printf("\n\n");
            }
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire