1 / 4
Sep 2020

the problem was: Life, the Universe, and Everything
my code on c++ is:
#include <stdio.h>
int main()
{
int i,q,n,num[1000];

//printf("\ninput:\n");
for(i=0; i<=5-1; i++)
{
 scanf("%d",&num[i]);

 	
 }

//printf("\noutput:\n");
i=0;
	  while(num[i]!=42)
 {
 printf("\n%d\n",num[i]);
 i++;
}

}

  • created

    Sep '20
  • last reply

    Sep '20
  • 3

    replies

  • 702

    views

  • 2

    users

  1. too many “\n” in the output
  2. You do not need that “for” at all
  3. you do not need array

i dont get it and then what do i do ?
does the numbers need to be fixed ,and if i dont need an array then how i do it , the “\n” is for calisthetics purposes

  1. Judge program do not cares about “calisthetics purposes”
  2. You need one instruction while.
  3. You need only varible num
    example pseudocode
    scan for num
    while (condition){
    print num and \n
    scan for num
    }