Python – C – 013

Python – C – 013: Please convert the following Python code to C so that the C program executes successfully passing the test cases.

N = int(input())
for ctr in range(N):
    currRow = list(map(int, input().strip().split()))
    print(len(currRow), sum(currRow))
#include<stdio.h>
#include<stdlib.h>
 int main()
 {
     int n,i;
     scanf("%dn",&n);
     for(i=1;i<=n;i++)
     {
         int l=0,s=0,num;
         char ch;
         while(1)
         {
             scanf("%d%c",&num,&ch);
             s=s+num;
             l++;
             if(ch=='n' || ch=='r')
                 break;
         }
         printf("%d %dn",l,s);
     }
 }
Previous Article

Zig-Zag Product Row

Next Article

Define class Test

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *