Answers

2014-07-23T12:04:57+05:30
#1
#include<stdio.h>
void main()
{
int rem,temp,sum=0;
printf("Enter the num:");
scanf("%d",&num);
temp=num;
while(num!=0)
{
rem=num%10;
sum=sum+rem;
num=num/10;
}
printf("Sum of digits of %d is %d",temp,sum);
getch();
}

#2

#include<stdio.h>
void main()
{
int sum=0,i,mark[5];
float avg;
for(i=0;i<5;i++)
{
printf("Enter mark of student[%d] : ",i+1)
 scanf("%d",&mark[i]);
for(i=0;i<5;i++)
 sum=sum+mark[i];
avg=sum/5;
printf("The average is %f",avg);
getch();
}
0