C Language practice

Arithmetics

Q1.Area of Circle for radius 12.5 ?

#include <stdio.h>
#include <math.h>
void main()
{ float R, area ;
  R = 12.5;
  area = M_PI*R*R;
  printf("area of circle is %f",area);                                                        

}


Using Array :

Q2. Sum of given sum of odd and even values?

#include<stdio.h>
#include<math.h>
void main()
{
    int a[10],i,even=0,odd=0;
    printf("Enter 10 values:");
    for(i=0;i<10;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]%2==0)
        even=even+a[i];
        //if(a[i]%2==1)
        else
        odd=odd+a[i];
 }
    printf("sum of given even values=%d",even);
    printf("\nsum of given odd values=%d",odd);

}


Comments