Skip to main content

Posts

First and Last Digit | FLOW004

Problem If Give an integer  N  . Write a program to obtain the sum of the first and last digits of this number. Input Format The first line contains an integer  T , the total number of test cases. Then follow  T  lines, each line contains an integer  N . Output Format For each test case, display the sum of first and last digits of  N  in a new line. Constraints 1 ≤ � ≤ 1000 1 ≤ T ≤ 1000 1 ≤ � ≤ 1000000 1 ≤ N ≤ 1000000 Sample 1: Input Output 3 1234 124894 242323 5 5 5 Solution: #include<bits/stdc++.h> using namespace std; int main() {    int t;    cin>>t;    while(t--)    {        int n;        cin>>n;        int rem = n%10;        while(n>9)        {            n = n/10;        }        cout<<n+rem<<endl; ...

ATM | HS08TEST

Problem Pooja would like to withdraw  X  $US from an ATM. The cash machine will only accept the transaction if  X  is a multiple of 5, and Pooja's account balance has enough cash to perform the withdrawal transaction (including bank charges). For each successful withdrawal the bank charges 0.50 $US. Calculate Pooja's account balance after an attempted transaction. Input Format Each input contains 2 integers  � X  and  � Y . � X  is the amount of cash which Pooja wishes to withdraw. � Y  is Pooja's initial account balance. Output Format Output the account balance after the attempted transaction, given as a number with two digits of precision. If there is not enough money in the account to complete the transaction, output the current bank balance. Constraints 0 < � ≤ 2000 0 < X ≤ 2000  - the amount of cash which Pooja wishes to withdraw. 0 ≤ � ≤ 2000 0 ≤ Y ≤ 2000  with two digits of precision - Pooja's initial account balance. S...

Chef And Operators | CHOPRT

Problem Chef has just started Programming, he is in first year of Engineering. Chef is reading about Relational Operators. Relational Operators are operators which check relationship between two values. Given two numerical values A and B you need to help chef in finding the relationship between them that is, First one is greater than second or, First one is less than second or, First and second one are equal. Input First line contains an integer T, which denotes the number of testcases. Each of the T lines contain two integers A and B. Output For each line of input produce one line of output. This line contains any one of the relational operators '<' , '>' , '='. Constraints 1 ≤ T ≤ 10000 1 ≤ A, B ≤ 1000000001 Sample 1: Input 3 10 20 20 10 10 10 Output < > = Explanation: In this example, 1 as 10 is lesser than 20 Solution: #include <iostream> using namespace std; int main() { // your code goes here int t; cin>>t; while(t--){    ...

Reverse The Number | FLOW007

Problem Given an Integer N, write a program to reverse it. Input The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer N. Output For each test case, display the reverse of the given number N, in a new line. Constraints 1 ≤ T ≤ 1000 1 ≤ N ≤ 1000000 Sample 1: Input 4 12345 31203 2123 2300 Output 54321 30213 3212 32 Solution: #include<iostream> using namespace std; int main(){     int t;     cin>>t;     while(t--)     {         int n;         cin>>n;         int ans=0;         while(n)         {             ans=ans*10+n%10;             n/=10;         }         cout<<ans<<endl;     }     return 0; }

Enormous Input Test | INTEST

Problem You are given N integers. Find the count of numbers divisible by K. Input Format The input begins with two positive integers N, and K. The next N lines contain one positive integer each denoted by A [i]. Output Format Output a single number denoting how many integers are divisible by K. Sample 1: Input 7 3 1 51 966369 7 9 999996 11 Output 4 Explanation: The integers divisible by 3 are 51, 966369, 9, and  999996. Thus, there are  4 integers in total. Solution: #include <bits/stdc++.h> using namespace std; int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);          int n,k;     cin >> n >> k;     int count=0;     for (int i=0;i<=n-1;i++)     {         int a;         cin >> a;         if (a%k==0)         {             count++;   ...

Add Two Numbers | FLOW001

Problem Problem Statement The task is very simple: given two integers A and B, write a program to add these two numbers and output it. Input Format The first line contains an integer T, the total number of test cases. Then follow T lines, each line contains two Integers A and B. Output Format For each test case, add A and B and display the sum in a new line. Everything your program prints is considered “output”, so if you output some debugging statements like “Please enter T”, this will be considered as part of your answer, and because it does not satisfy the output format, it will be marked wrong, even if your answer is otherwise correct! Constraints 1 ≤ T ≤ 1000 0 ≤ A,B ≤ 10000 Sample 1: Input 3 1 2 100 200 10 40 Output 3 300 50 Solution: #include <iostream> #include <bits/stdc++.h> using namespace std; int main()  {    int t;    cin>>t;    int a,b;    while(t--){     int sum=0;     cin>>a>>...