Problem You're given an integer N . Write a program to calculate the sum of all the digits of N . Input Format The first line contains an integer T , the total number of testcases. Then follow T lines, each line contains an integer N . Output Format For each test case, calculate the sum of digits of N , and display it in a new line. Constraints 1 ≤ � ≤ 1000 1 ≤ T ≤ 1000 1 ≤ � ≤ 1000000 1 ≤ N ≤ 1000000 Sample 1: Input Output 3 12345 31203 2123 15 9 8 Solution: #include <bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--) { int n; cin>>n; int sum = 0; while(n!=0) { int r = n%10; sum+= r; ...
Problem Write a program to find the remainder when an integer A is divided by an integer B . Input The first line contains an integer T , the total number of test cases. Then T lines follow, each line contains two Integers A and B . Output For each test case, find the remainder when A is divided by B , and display it in a new line. Constraints 1 ≤ T ≤ 1000 1 ≤ A,B ≤ 10000 Sample 1: Input Output 3 1 2 100 200 40 15 1 100 10 Solution: #include<iostream> using namespace std; int main(){ int t; cin>>t; while(t--){ int a, b; cin>>a>>b; cout<<a%b<<endl; } return 0; }