Program To Display Sum And Average Of All Digits That Are Divisible By 3 Upto The Given Number
/* Program To Display Sum And Average Of All Digits That Are Divisible By 3 Upto The Given Number */ #include
#include
void main() { int i=1,sum=0,n,j=0; float avg; clrscr(); printf("\nEnter the value\n\n"); scanf("%d",&n); while(i<=n) { if((i%3)==0) { sum = sum+i; j++; } i++; } avg = (float)sum/j; printf("\nsum = %d\n\navg = %f",sum,avg); getch(); }
Please send comments to
vgdarur.javafive@blogger.com
Copyright © 2008 - iForeRunner.com
http://www.iforerunner.com/