While loop example Write a 'c' program to find the sum of digits of a number using while loop e.g. num = 456 sum=4+5+6= 15 #include<stdio.h> #include<conio.h> main() { int num,sum; clrscr( ); printf("\nEnter the number :"); scanf("%d",&num); sum=0; while(num!=0) { sum=sum+num%10; num=num/10; } printf("\nSum of digits = %d",sum); getch(); }
FOR EVERY PROGRAMMER SOME SPECIAL PROGRAMS WITH THEORY.