0
I’m having trouble creating a program that prints whether the number typed is triangular or not. How should I proceed to create within the conditional an undefined sequence for a large number?
#include <stdio.h>
int main (void)
{
int num, i, aux;
scanf("%d", &num);
num = n*(n + 1)/2;
for(i = 1; i + (i + 1)<=num; i++ )
{
if(i + (i + 1) + (i + 2) == num)
aux = 1;
}
if (aux)
{
printf("SIM");
}
else
{
printf("NAO");
}
return 0;
}
The variable
aux
was not initialized.– pmg