Tech Study

write a c program to print sum of digits

Introduction

Write a C program to print sum of digits enter by user

#include<stdio.h>

int main()
{
    int num, total;

    //Reading number
    printf("Enter any number: ");
    scanf("%d", &num);

    //Adding sum of digit in total variable
    for(total = 0; num > 0; num = num/10)
        total = total + (num%10);

    //Printing sum of digit
    printf("Sum of digits: %d", total);

    return 0;
}

Result

Write a C program to print sum of digits enter by user
Sum of Even Numbers in C till N

TaggedWrite a C program to print sum of digits enter by user

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more