Monday, November 13, 2017

Add Two Numbers Codechef Problem Solution In ( C++, C# )

https://www.codechef.com/problems/FLOW001


In C#................

using System;



    public class Program
    {
    
        public static void Main()

        {
            int T = Convert.ToInt32(Console.ReadLine());
            for (int i = 0; i < T;i++ )
            {
                string s = Console.ReadLine();
                string[] values = s.Split(' ');
                int a = int.Parse(values[0]);
                int b = int.Parse(values[1]);
                Console.WriteLine(a+b);
               }
            Console.ReadKey();
               
        }

    }
   
In C++....




  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6.  
  7. {
  8. int t;
  9. cin>>t;
  10. while(t--)
  11. {
  12. int a,b;
  13. cin>>a>>b;
  14. cout<<a+b<<endl;
  15.  
  16. }
  17. return 0;
  18. }

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Why here using while loop for adding two element in c++.

    ReplyDelete