1). #include <stdio.h>
#include <stdlib.h>
int main()
{
int x=0;
while(x<=100)
{
printf("%d ",x);
x++;
}
return 0;
}
2). #include <stdio.h>
#include <stdlib.h>
int main()
{
int x=0;
while(x<=100)
{
printf("%d ",x);
printf("\n");
x++;
}
int y=0 ,sum;
do {
printf("%d ",y);
y++;
}
while (y<=100);
return 0;
}
3). #include <stdio.h>
#include <stdlib.h>
int main()
{
int count,marks=0,total=0;
float average=0;
while(count<10){
printf("Enter the marks for the subject \n");
scanf("%d",&marks);
total=marks+total;
count++;
}
average=total/10;
printf("the average is :%f",average);
printf("the total is \n",&total);
if(average<50)
{
printf("fail");
}
else
{
printf("pass");
}
}
4). #include <stdio.h>
#include <stdlib.h>
int main()
{
nt num, i=1, factorial;
factorial=1;
printf("enter the number to find the factorial:");
scanf("%d",&num);
while(i<=num)
{
factorial*=i;
i++;
}
printf("the factorial of %d is : %d",num,factorial);
return 0;
}
5). #include <stdio.h>
#include <stdlib.h>
int main()
{
int num, sum=0;
printf("enter the number: \n");
scanf("%d",&num);
while(num !=0)
{
sum=sum + num%10;
num=num/10;
}
printf("%d",sum);
return 0;
}