Generally ‘+’ operator is used to add two numbers but in the following C# program there are add two numbers without using ‘+’ operator.
Program:
using System;
public class Program
{
public static void Main()
{
int a=6,b=15;
Console.Write('Sum of '+a+' and '+b+' is : ');
while(b!=0)
{
a++;
b--;
}
Console.WriteLine(a);
}
}
Output: Sum of 6 and 15 is : 21
Input number in runtime by user.
Program:
using System;
public class Program
{
public static void Main()
{
int a,b;
Console.Write('Enter the first number ');
a=int.Parse(Console.ReadLine());
Console.Write('Enter the second number ');
b=int.Parse(Console.ReadLine());
Console.Write('Sum of '+a+' and '+b+' is : ');
while(b!=0)
{
a++;
b--;
}
Console.WriteLine(a);
}
}
Output:
Enter the first number 14
Enter the second number 210
Sum of 14 and 210 is : 224
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Generally ‘+’ operator is used to add two numbers but in the following C# program there are add two numbers without using ‘+’ operator.
Program:
Input number in runtime by user.