Input output sample - 02Input Specification:Input file will consist of several lines. Each line contains two integers a and b. Input is terminated by a line containing two zeroes. This line should not be processed. Output Specification: For each line of input produce one line of output. This line contain the value of c, where c = a*b. After each test case, you should print a blank line. Sample Input: 2 2 3 3 0 0 Sample Output: 4 9 Pascal Code:
program sample2 (input, output); var a,b: integer; begin while not eof(input) do begin readln(a,b); if (a=0) and (b=0) then break; writeln(a*b); writeln(''); end; end. C Code: #include <stdio.h> int main(){ int a,b,c; while(scanf("%d %d",&a,&b)==2){ if(a==0&&b==0)break; c = a*b; printf("%d\n\n",c); } return 0; } C++ Code: #include <iostream> using namespace std; int main(){ int a,b,c; while(cin>>a>>b){ if(a==0&&b==0)break; c = a*b; cout<<c<<endl<<endl; } return 0; } Java Code: import java.io.*; import java.util.*; class Main{ public static void main (String args[]) throws IOException{ BufferedReader bf = new BufferedReader( new InputStreamReader ( System.in )); StringTokenizer token; String input; int a,b,c; while((input = bf.readLine())!=null){ token = new StringTokenizer(input); a = Integer.parseInt(token.nextToken()); b = Integer.parseInt(token.nextToken()); if(a==0 && b==0)break; c = a*b; System.out.println(c); System.out.println(); } } } |
||