Input output sample - 01Input Specification:Input starts with an integer T , denoting the number of test cases. Each test case will contain two integers a and b. Output Specification: For each test case, output one line in the format “Case x: c” (quotes for clarity), where x is the case number and c is the sum of a and b . Sample Input: 2 5 10 9 4 Sample Output: Case 1: 15 Case 2: 13 Pascal Code: program sample1 (input, output); var a,b,c,cas,i: integer; begin readln(cas); for i:=1 to cas do begin readln(a,b); c:=a+b; Writeln('Case ',i,': ',c); end; end. C Code : #include <stdio.h> int main(){ int cas,i,a,b,c; scanf("%d",&cas); for(i=1;i<=cas;i++){ scanf("%d %d",&a,&b); c=a+b; printf("Case %d: %d\n",i,c); } return 0; } C++ Code: #include <iostream> using namespace std; int main(){ int cas,i,a,b,c; cin>>cas; for(i=1;i<=cas;i++){ cin>>a>>b; c=a+b; cout<<"Case "<<i<<": "<<c<<endl; } return 0; } Java Code:
import java.util.*; class Main{ public static void main(String args[]){ int cas,i,a,b,c; Scanner sc = new Scanner(System.in); cas = sc.nextInt(); for(i=1;i<=cas;i++){ a = sc.nextInt(); b = sc.nextInt(); c = a+b; System.out.println("Case "+i+": "+c); } } } |
||