# 1.write an Algorithm in c for adding digits of a given number?2. write an algorithm in c that will calculate the average and total of 5 students for 3 subjects?

Program 1 :

// C program to compute sum of digits in
// number.
#include <stdio.h>

/* Function to get sum of digits */
int getSum(int n)

int sum = 0;
while (n != 0)
sum = sum + n % 10;
n = n / 10;

return sum;

// Driver code
int main()

int n = 687;
printf(" 0 ", getSum(n));
return 0;

Program 2:

#include<stdio.h>
#include<conio.h>
void main()

int n,i;
float avg[5],s1[5],s2[5],s3[5],sum[5];
clrscr();
for(i=0;i<5;i++)

printf(" Enter marks of students 0 in 3 subjects:",i+1);
scanf("000",&s1[i],&s2[i],&s3[i]);

for(i=0;i<5;i++)

sum[i]=s1[i]+s2[i]+s3[i];
avg[i]=sum[i]/3;

for(i=0;i<5;i++)
printf(" Student 0's marks: Total : %.2f Average : %.2f",i+1,sum[i],avg[i]);
getch();

## Most Viewed Questions

### Preparation Products

##### Knockout JEE Main April 2021 (One Month)

Personalized AI Tutor and Adaptive Time Table, Self Study Material, Weekend Live Classes, Mentorship from our Experts, Unlimited Mock Tests and Personalized Analysis Reports, 24x7 Doubt Chat Support,.

₹ 14000/- ₹ 4999/-
##### Knockout NEET Aug 2021 (One Month)

Personalized AI Tutor and Adaptive Time Table, Self Study Material, Weekend Live Classes, Mentorship from our Experts, Unlimited Mock Tests and Personalized Analysis Reports, 24x7 Doubt Chat Support,.

₹ 14000/- ₹ 4999/-
##### Knockout JEE Main May 2021

Personalized AI Tutor and Adaptive Time Table, Self Study Material, Weekend Live Classes, Mentorship from our Experts, Unlimited Mock Tests and Personalized Analysis Reports, 24x7 Doubt Chat Support,.

₹ 22999/- ₹ 9999/-
##### Knockout NEET Aug 2021

Personalized AI Tutor and Adaptive Time Table, Self Study Material, Weekend Live Classes, Mentorship from our Experts, Unlimited Mock Tests and Personalized Analysis Reports, 24x7 Doubt Chat Support,.

₹ 22999/- ₹ 9999/-