Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How do i do magic numbers?

+1 vote
asked May 16, 2018 by aaqib lakhani (130 points)

2 Answers

0 votes
answered May 29, 2018 by dwip neel (190 points)
#include <stdio.h>

int

main ()

{

  int a, b, sum, i;

  a = 1;

  b = 100;

  while (a <= b)

    {

      sum=0;

      for (i = 1; i < a; i++)

{

  if (a % i == 0)

    sum = sum + i;

}

      if (a == sum)

printf ("%d\n", a);

      a++;

    }

}
0 votes
answered May 29, 2018 by Un poco de Todo (140 points)

#include <stdio.h>

#define N 3 //definimos una constante de valor 3 esta queda a criterio del programador

int main()

{

int vector[N], i;

srant(time(NULL)); //inicializamos la funcion que permite generar numeros aleatorios

for(i=0; i<N; i++)  //recorremos el vector y alojamos los numeros que se generan en sus tres posiciones

{

vector[i]=rand()%10; //genera numeros aleatorios que oscilan entre 0 y 9 y lo coloca en la posicion i de vector

}

return 0;

}

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...