Thursday, June 4, 2020
Program to add two number in C
Write a C Program to add two numbers by taking input from user. Have a look at the below example and step by step logic to add two numbers.
Before writing any program you just imagine about output screen first. Like what input to be given, and output to be displayed. Let's have a look at the below example.
Required knowledge for this exercise is:
Logic to add two numbers:
1) Print a massage to the user like "Enter two numbers:" using printf();
2) Input number from user and store it in a variables num1 & num2 using scanf();
3) Calculate sum of two numbers using farmula sum = num1 + num2;
4) At last print the value of sum. that's it!
Program to find sum of two numbers input givien by a user :
Output:
You can take input separately for each number by using scanf().
For Example:
OR
Above statements can also write like this:
Next topic >> to be updated soon.
Help others by sharing this page.
Ahmad Irshad
Author & Editor
I love blogging, teaching, learning computer science and sharing it to others. I've written and develped this site so that students may learn computer science related tutorials eaisly. MCA / MCITP
Thursday, June 04, 2020
C
Subscribe to:
Post Comments (Atom)
0 Comments:
Post a Comment
Please don't enter any spam link in the comment box.