blank
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int fun(char *s)
{ int sum=0;
while(*s) {
/found/
if( isdigit(s) ) sum+= s- 48 ;
/found/
s++;
}
/found/
return sum ;
}
void main()
{ char s[81]; int n;
printf("\nEnter a string:\n\n"); gets(s);
n=fun(s);
printf("\nThe result is: %d\n\n",n);
}
modi
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
int fun(int k)
{ int m=0,mc=0, j;
while((k>=2)&&(mc<10))
{
/found/
if((k%130)||(k%170))
{ m=m+k;mc++;}
k–;
/found/
}
return m;
}
void main()
{system(“CLS”);
printf("%d\n ",fun(500));
}
prog
#include <math.h>
#include <stdio.h>
double fun( int n)
{
double sum=0.0;
int i;
for(i=21; i<=n; i++)
if((i % 30) && (i % 70)) sum+=i;
return sqrt(sum) ;
}
main()
{ void NONO ();
printf(“s =%f\n”, fun ( 1000) );
NONO();
}
void NONO ()
{
FILE *fp, *wf ;
int i, n ;
double s;
fp = fopen(“in.dat”,“r”) ;
wf = fopen(“out.dat”,“w”) ;
for(i = 0 ; i < 10 ; i++) {
fscanf(fp, “%d”, &n) ;
s = fun(n) ;
fprintf(wf, “%f\n”, s) ;
}
fclose(fp) ;
fclose(wf) ;
}