Saturday, 27 July 2013

C-Program to Find The Product of Squares Of Natural Numbers Upto a Limit

#include<stdio.h>
main ()
{
int prdct=1,n,i;
  printf("Enter the Limit\t");
scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
prdct=prdct*i*i;
}
printf("Product of Squares Upto %d is %d",n,prdct);
}






sakoncepts.blogspot.com
output

C-Program To Find The Product Of Natural Numbers Divisible by a particular Number Given by the user Upto a limit

#include<stdio.h>
main ()
{
int prdct=1,n,i,d;
printf("Enter the Limit\t");
scanf("%d",&n);
printf("Enter the Divisible\t");
scanf("%d",&d);
for(i=d;i<=n;i=i+d)
{
if(i%d==0)
{
prdct=prdct*i;
}
}
printf("Product of Numbers Divisible By %d upto %d is %d",d,n,prdct);
}




sakoncepts.blogspot.com
output

C-Program To Find Product of Natural Numbers divisible By 3 Up to a Limit

#include<stdio.h>
main ()
{
int prdct=1,n,i;
printf("Enter the Limit\t");
scanf("%d",&n);
for(i=3;i<=n;i=i+3)
{
if(i%3==0)
{
prdct=prdct*i;
}
}
printf("Product of Numbers Divisible By three Upto %d is %d",n,prdct);
}







sakoncepts.blogspot.com
output

C-Program To Find the Product Of CUBES of Natural Numbers UP to a Limit

#include<stdio.h>
main ()
{
int prdct=1,n,i;
printf("Enter the Limit\t");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
prdct=prdct*i*i*i;
}
printf("Product of Cubes Upto %d is %d",n,prdct);
}





sakoncepts.blogspot.com
output



C-Program To Find The Product Of Even Natural Numbers Ut To a Limit

#include<stdio.h>
main ()
{
int prdct=1,n,i;
printf("Enter the Limit\t");
scanf("%d",&n);
for(i=1;i<=n;i=i++)
{
if(i%2==0)
{
prdct=prdct*i;
}
}
printf("Product of Even Numbers Upto %d is %d",n,prdct);
}





sakoncepts.blogspot.com
output

C-Program To Find Product Of odd Natural Numbers Up to a Limit

#include<stdio.h>
main ()
{
int prdct=1,n,i;
printf("Enter the Limit\t");
scanf("%d",&n);
for(i=1;i<=n;i=i+2)
{
if(i%2!=0)
{
prdct=prdct*i;
}
}
printf("Product of OddNumbers Upto %d is %d",n,prdctOO);
}





sakoncepts.blogspot.com
output

C-Program To Find The PRODUCT of Natural Numbers Upto a Limit

#include<stdio.h>
main ()
{
int product=1,n,i;
printf("Enter the Limit\t");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
product=product*i;
}
printf("Product of Numbers Upto %d is %d",n,product);
}





sakoncepts.blogspot.com
output

C-Program To Find SUM of Natural Numbers Divisible by a Number Given By user Upto a Limit

#include<stdio.h>
main ()
{
int sum=0,n,i,d;
printf("Enter the Limit\t");
scanf("%d",&n);
printf("Enter the Divisible\t");
scanf("%d",&d);
for(i=d;i<=n;i=i+d)
{
if(i%d==0)
{
sum=sum+i;
}
}
printf("Sum of Numbers Divisible By %d upto %d is %d",d,n,sum);
}





sakoncepts.blogspot.com
output

C-Program To Find SUM of Natural Numbers Divisible By 3 Upto a Limit

#include<stdio.h>
main ()
{
int sum=0,n,i;
printf("Enter the Limit\t");
scanf("%d",&n);
for(i=3;i<=n;i=i+3)
{
if(i%3==0)
{
sum=sum+i;
}
}
printf("Sum of Numbers Divisible By three Upto %d is %d",n,sum);
}





sakoncepts.blogspot.com
output

C-Program To Find The SUM of CUBES of Natural Numbers Upto a Limit

#include<stdio.h>
main ()
{
int sum=0,n,i;
printf("Enter the Limit\t");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
sum=sum+i*i*i;
}
printf("Sum of Cubes Upto %d is %d",n,sum);
}







sakoncepts.blogspot.com
output



C-Program To Find SUM of SQUARES of Natural Numbers Upto a Limit

#include<stdio.h>
main ()
{
int prdct=1,n,i;
printf("Enter the Limit\t");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
prdct=prdct*i*i;
}
printf("Product of Squares Upto %d is %d",n,prdct);
}



sakoncepts.blogspot.com
output


C-Program To Find The SUM of EVEN Numbers Upto a Limit

#include<stdio.h>
main ()
{
int sum=0,n,i;
printf("Enter the Limit\t");
scanf("%d",&n);
for(i=0;i<=n;i=i+2)
{
if(i%2==0)
{
sum=sum+i;
}
}
printf("Sum of Even Numbers Upto %d is %d",n,sum);
}


sakoncepts.blogspot.com
output


C-Program To Find The SUM Of ODD Numbers Upto a Limit

#include<stdio.h>
main ()
{
int sum=0,n,i;
printf("Enter the Limit\t");
scanf("%d",&n);
for(i=1;i<=n;i=i+2)
{
if(i%2!=0)
{
sum=sum+i;
}
}
printf("Sum of Odd Numbers Upto %d is %d",n,sum);
}



sakoncepts.blogspot.com
output

C-Program To Find The Biggest Number Among n Numbers (Biggest in an Array)

#include<stdio.h>
main ()
{
int n,i,j,big,a[50];
printf("Enter the Number of elements\t");
scanf("%d",&n);
printf("Enter the elemnts\t");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
big=a[i];
}
}
}
printf("The biggest Number is %d",big);
}



sakoncepts.blogspot.com
output

C-Program To Find Biggest among Three numbers using Conditional Operator

#include<stdio.h>
main ()
{
int a,b,c,biggest;
printf("Enter the three Numbers\t");
scanf("%d%d%d",&a,&b,&c);
if((a==b)&&(b==c))
{
printf("You Entered The Identical Number %d",a);
exit(0);
}
biggest=(a>b?a:b);
biggest=(biggest>c?biggest:c);
printf("BIGGEST Number Among %d %d %d is %d",a,b,c,biggest);
}






sakoncepts.blogspot.com
output

C-Program To Find The Biggest Number Among Three Numbers Using IF statement

#include<stdio.h>
main ()
{
int a,b,c,biggest;
printf("Enter the three Numbers\t");
scanf("%d%d%d",&a,&b,&c);
if((a==b)&&(b==c))
{
printf("You Entered The Same Element %d",a);
exit(0);
}
if(a>b)
biggest=a;
else
biggest=b;
if(biggest>c)
printf("BIGGEST Number Among %d %d %d is %d",a,b,c,biggest);
else
printf("BIGGEST Number Among %d %d %d is %d",a,b,c,c);
}





sakoncepts.blogspot.com
output

Wednesday, 24 July 2013

C-Program to Find AVERAGE of n Numbers (Average of Elements in an Array)

#include<stdio.h>
main ()
{
int a[50],i,n,sum=0;
float avg;
printf("Enter the no.of elements\t");
scanf("%d",&n);
printf("\nEnter the elements\t");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
avg=(float)sum/(float)n;
printf("Average of given %d elements in the array is %f",n,avg);
getch();
}




sakoncepts.blogspot.com
output

C-Program to Find AVERAGE of Five Numbers

#include<stdio.h>
main ()
{
int a,b,c,d,e,sum=0;
float avg;
printf("Enter the five numbers\t");
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
sum=a+b+c+d+e;
avg=(float)sum/5;
printf("Average of the numbers %d %d %d %d %d is \t%f\n",a,b,c,d,e,avg);
}



sakoncepts.blogspot.com
output

C-Program to SUM of Elements Stored in an Array

#include<stdio.h>
main ()
{
int sum=0,n,i,a[50];
printf("Enter the number of elements\t");
scanf("%d",&n);
printf("\nEnter the numbers\t ");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
printf("\nSum of given Numbers is %d",sum);
}


sakoncepts.blogspot.com
output

C-Program to SUM of Numbers Upto a Limit (SUM of Natural Numbers Upto a Limit)


catogory:
tags:


Concept Introduction :

             Find the sum of Natural numbers upto a limit.
For example:
natural numbers are  1 2 3 4 5 6 7 8 9 10 .....etc
if input is 4, output is 1+2+3+4=10 and
if input is 7,output is 1+2+3+4+5+6+7=28

Below program helps you to find sum of natural numbers upto your choices

How to Implement :

            First initialize a variable sum(just say) as zero to clear previous values in that variable.
Read more...

Implementation in C language :
  
#include<stdio.h>
main ()
{
      int n,sum=0,i;
      printf("Enter the limit\t");
      scanf("%d",&n);
      for(i=1;i<=n;i++)
     {
           sum=sum+i;
     }
     printf("Sum of numbers upto %d is \t%d",n,sum);




sakoncepts.blogspot.in
output


C-Program to SUM of Two Numbers

#include<stdio.h>
main ()
{
int a,b,sum=0;
printf("Enter the two numbers\t ");
scanf("%d%d",&a,&b);
sum=a+b;
printf("sum of %d and %d is %d",a,b,sum);
getch();
}



sakoncepts.blogspot.com
output


C-Program to Print a line or a Paragraph

#include<stdio.h>
main ()
{
     printf(" (write youe content here....use '\n' for next line and '\t' for space) ");
}



sakoncepts.blogspot.in
output