Sum of Input value | C-Program

Sum of Input value:

 

Code:

#include<stdio.h>

void main()

{

    int n,a,b=0;

    printf("Enter a number :\n");

    scanf("%d",&n);

    while(n!=0)

    {

      a=n%10;

      n=n/10;

      b=b+a;

    }

    printf("The sum is :%d\n",b);

}

Output:



Popular posts from this blog

TOP 10 PROGRAMMING LANGAUAGES COMMING 2021 | ARTICLE

Write a C-program to swap two number:

Print Fibonacci Series using Recursion | C program :