Monday 31 December 2018

Find Average Of Odd Numbers Below A Range[c programming examples with output]

C programming examples with output

Find Average Of Odd Numbers Below A Range
Program

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c,d;
float f;
clrscr();
printf("Enter the range: ");
scanf("%d",&b);
a=1;c=0;d=0;
while(a<=b)
{
            if(a%2!=0)
      {
d=d+a;
c++;
}
           a++;
}
f=d/c;
printf("\nThe average of odd numbers below %d: %f",b,f);
getch();
}


Output
Enter the range:20
The average of odd numbers below 20: 10.000000


Check others programming by click here:

Find perfect number or not[c programming examples with output]

C programming examples with output

Find perfect number or not
Program

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf("Enter any number: ");
scanf("%d",&a);
b=1;
c=0;
while(b<a)
{
           if(a%b==0)
           c=c+b;
           b++;
}
if(c==a)
                printf("%d is a Perfect number",a);
else
                printf("%d is not a Perfect number",a);
getch();
}

Output
Enter any number: 6
6 is a Perfect number
Enter any number:33
33 is not a Perfect number


Check others programming by click here:

Even number upto a range[c programming examples with output]

C programming examples with output

Even number upto a range
Program

#include<stdio.h>
#include<conio.h>
main()
{
int a,b;
clrscr();
printf("Enter the range: ");
scanf("%d",&a);
b=1;
while(b<=a)
{
        if(b%2==0)
          printf("%d/t",b);
          b++;
}
getch();
}

Output
Enter the range:10

Find biggest number out of three numbers [c programming examples with output]

C programming examples with output

Find the biggest number out of three numbers
Program:

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf("Enter any three numbers : ");
scanf("%d%d%d",&a,&b,&c);
if((a>b) && (a>c))
    printf("The big number: %d",a);
else if(b>c)
          printf("The big number: %d",b);
else
          printf("The big number: %d,c);
getch();
}

Output
Enter any three numbers :1
2
3