You are not logged in. Please login at www.codechef.com to post your questions!

×

TEST - Editorial

PROBLEM LINK:

Practice

Author: ADMIN

Editorialist: SUSHANT AGARWAL

DIFFICULTY:

CAKEWALK

PREREQUISITES:

Basic looping,Basic Input/Output

PROBLEM:

Rewrite small numbers from input to output. Stop processing input after reading in the number 42. All numbers at input are integers of one or two digits.

EXPLANATION:

Please refer to the sample solution given by editorialist.

EDITORIALIST'S SOLUTION:

Editorialist's solution can be found here.

This question is marked "community wiki".

asked 17 Dec '14, 14:23

sushant96's gravatar image

0★sushant96
21368
accept rate: 0%

edited 02 Jan '15, 17:25

admin's gravatar image

0★admin ♦♦
19.0k348495533


123next »

#include<iostream.h>

void main()
{
 int a,flag=0;
 do
 { 
  cin>>a;
  if(a<=99 && a>=(-99) && a!=42)
  {
   flag=1;
   cout<<a;
  }
 }while(flag==1); 
}
link

answered 02 Jan '15, 18:07

robo_kingg_01's gravatar image

0★robo_kingg_01
1
accept rate: 0%

edited 02 Jan '15, 19:36

betlista's gravatar image

3★betlista ♦♦
16.9k49115225

import java.util.*; public class inToOut{

public static void main(String [] args)
{
    Scanner in = new Scanner(System.in);
    while(in.hasNextInt() )
    {
        int temp = in.nextInt();
        if(temp == 42)
            break;
        System.out.println(temp);
    }

}

}

link

answered 23 Jan '15, 16:46

lkalig2's gravatar image

0★lkalig2
1
accept rate: 0%

include<stdio.h>

int main() {int i,b[100]; for(i=0;i<100;i++) {scanf("%d\n",&b[i]); if(b[i]==42) break; else printf("%d\n",b[i]); } return 0;}

link

answered 27 Jan '15, 10:21

ashish66's gravatar image

1★ashish66
1
accept rate: 0%

edited 27 Jan '15, 10:28

include<stdio.h>

int main() { int a=1; while(a>=(-99) && a<=99) { scanf("%d",&a); if(a!=42) printf("%d\n",a); else break; } return 0; }

link

answered 01 Feb '15, 23:33

sonalisahu64's gravatar image

0★sonalisahu64
1
accept rate: 0%

edited 02 Feb '15, 00:13

include<stdio.h>

include<conio.h>

void main() { int x; printf("\n Enter a two digit no to stop enter 42 "); scanf("%d",&x); if((x>99)||(x=42)) break; else printf("the entered no is : %d",x); }

link

answered 11 Feb '15, 19:32

sanjana12's gravatar image

0★sanjana12
1
accept rate: 0%

Don't give statements like 'Enter number' etc. Directly take input and print output in the given format.

(11 Feb '15, 21:18) drgn_hart2★

include<stdio.h>

main() { int num=0; while(num<100) { scanf("%d",&num); if(num!=42) printf("%d",num); else continue; }

link

answered 08 Mar '15, 23:27

zufrieden's gravatar image

2★zufrieden
1
accept rate: 0%

/this is corect answer even tho sowing false/

include <stdio.h>

int main () {
int n;
for (;n!=42;)
{
scanf ("%d",&n);

printf ("%d\n",n);} return 0; }

link

answered 13 Mar '15, 22:47

prerak13's gravatar image

0★prerak13
1
accept rate: 0%

import java.util.Scanner;

public class LifeTheUniverseAndEverything {

public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    while (true) {
        int i = scanner.nextInt();
        if (i == 42)
            break;
        System.out.println(i);
    }

}

}

link

answered 23 Mar '15, 14:30

vipulchauhan's gravatar image

0★vipulchauhan
1
accept rate: 0%

include<stdio.h>

int main(void) { unsigned int num; for(;printf("%d",scanf("%d",&num)!=42);); return(0); }

link

answered 04 Apr '15, 20:34

prash_7's gravatar image

0★prash_7
1
accept rate: 0%

import java.util.Scanner;

/ * @author Avi / public class New {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    // TODO code application logic here
    int poda[];
    poda = new int[10];
    Scanner input = new Scanner(System.in);
    System.out.println("enter the array");
    for (int i =0;i<5;i++)
    {
        poda[i]=input.nextInt();                    
    }

    System.out.printf("the output values are ");
     for (int i =0;i<5;i++)
     {
     if(poda[i]==42)
        {
            break;
        }
         System.out.println(poda[i]);
     }
}

}

link

answered 02 May '15, 15:14

avinashv37's gravatar image

0★avinashv37
1
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,434
×155
×39

question asked: 17 Dec '14, 14:23

question was seen: 8,940 times

last updated: 12 Oct '17, 22:59