Home / C / C program to add two numbers using for loop

C program to add two numbers using for loop

C program to add two numbers using for loop | Sum of two numbers using for loop : This is a c program to add two numbers using for loop to know more concept about the looping and conditional control statements. 

Also Read : C program for sum of two numbers using while loop

#CODE for Sum of two numbers using for loop and functions

#include <stdio.h>

int sum(int, int);
int main() {
   int a, b;

   printf("Enter the two Numbers: ");
   scanf("%d %d", &a, &b); 

   printf("Addition of two num. is : %d", sum(a, b));
   return(0);
}

int sum(int num1, int num2) {
   int i;
   for (i = 0; i < num2; i++)
      num1++;
   return num1;
}

OUTPUT:

Enter the two numbers: 12 3
Addition of two num. is : 15

Incoming terms:

Write a program in C to add two numbers using for loop

WAP to add two numbers using for loop

 

Check Also

Restrict Mouse Pointer Position C Graphics Program

This C Program will restrict the Mouse Pointer location or to a particular position or x,y ...

Leave a Reply

Your email address will not be published. Required fields are marked *

Preventing spam * Time limit is exhausted. Please reload the CAPTCHA.