How to Write Your Code
Welcome to TechGig's How to write your code section.
Please register yourself at TechGig as it is free and simple. Then navigate to the bottom of the page to come back to “How to write your code” section. Here, we have a list of successful sample solutions for different languages for a sample problem: Addition of Two Numbers
Addition of Two Numbers:
Given two numbers a and b, you have to find the summation of a and b.
Input:
Two space separated integers, a and b
Output:
Summation of a and b
Solutions in different languages for Addition of Two Numbers are written below.
Provide all the solutions from Platform FAQ -> Run Code on Local Machine section
Click on the Try Now button below every solution to try the code on your own. When you click on the Try Now button, you will be navigated to the sample test screen with a challenge “Try Now”. Click on Solve Problem button to take the test and submit your details in the Registration Form followed by Submit button. Go through the instructions for the test carefully as it helps you to feel at ease during the test. Test screen will open on your screen with problem statement, Input and Output specification and the coding editor. Select the language you wish to code in from Select Language list and start writing your code. There are several other features that can be used while coding on TechGig’s platform.
- Upload Code as File: A pop-up will display on your screen for confirmation. Click on Yes button if you wish to upload a file. Click on Browse button on the Source File section and upload your code as a text file with extension of your preferred language. For example: If you a uploading your code in Java, then your file should have the extension “.java”. If you wish to see a sample file, download the sample file from Download link displaying adjacent to this section.
- Full Screen Mode: You can now code your problem in full screen mode by clicking on this button.
- Keyboard Shortcuts: You can identify all the keyboard shortcuts that you can use while coding on TechGig's platform.
- Settings: Select any new theme from this section. Change the font size and style easily. Enable or disable Auto Complete setting.
After you have written all your code, click on Compile & Run Code button to compile your code for evaluation. Results for compilation will display to you within seconds on the bottom of the page as Compilation Log. Submit your code by clicking on Submit Code button if you find the code as perfect for the problem. You can also check your custom input by sending the input value through Own Test Case button. Click on Continue to list questions button to view all the list of questions. Click on Submit Test button to submit your test and view the results.
Solutions in different languages for Addition of Two Numbers are written below:
C
Code for Addition of Two Numbers on TechGig Code Editor:/* Read input from STDIN. Print your output to STDOUT*/ #include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int addition(int a, int b) { return a+b; } int main() { int num1,num2; scanf("%d %d",&num1,&num2); int sum; sum = addition(num1,num2); printf("%d\n",sum); return 0; }
Now you can test this code with same compiler and version used by TechGig Engine(see Compilers and their Versions)-
Try Now
C#
Code for Addition of Two Numbers on TechGig Code Editor:/* Read input from STDIN. Print your output to STDOUT*/ using System; using System.Collections.Generic; using System.IO; class CandidateCode { static int addition(int a, int b) { return a+b; } static void Main(String[] args) { int val1 = Convert.ToInt32(Console.ReadLine()); int val2 = Convert.ToInt32(Console.ReadLine()); int sum = addition(val1,val2); Console.WriteLine(sum); } }Try Now
JAVA
Code for Addition of Two Numbers on TechGig Code Editor:/* Read input from STDIN. Print your output to STDOUT*/ import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; class CandidateCode { static int addition(int a, int b) { return a+b; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int a; a = in.nextInt(); int b; b = in.nextInt(); int sum; sum = addition(a, b); System.out.println(sum); } }
Try Now
PYTHON
Code for Addition of Two Numbers on TechGig Code Editor:''' Read input from STDIN. Print your output to STDOUT ''' #Use input() to read input from STDIN and use print to write your output to STDOUT def addition(a,b): return a+b num1 = input() num2 = input() res = addition(num1,num2) print res
Try Now
PHP
Code for Addition of Two Numbers on TechGig Code Editor:<?php function addition($a,$b){ return $a + $b; } $handle = fopen ("php://stdin","r"); $_a = fgets($handle); $_b = fgets($handle); $sum = addition((int)$_a,(int)$_b); print ($sum)."\n"; fclose($handle); ?>
Try Now
PERL
Code for Addition of Two Numbers on TechGig Code Editor:# Read input from STDIN. Print your output to STDOUT sub addition{ ($x,$y) = @_; $res = $x + $y; return $res ; } $choice1 =; $choice2 = ; $res = addition($choice1 , $choice2); print "$res\n" ;
Try Now
Social Login