any one can help me ??
PROGRAM TO FIND SUM OF INDIVIDUAL DIGITS OF A NUMBER
PHP Code:
#include <stdio.h>
#include <conio.h>
void main()
{
int a,n,final,sum=0;
clrscr();
printf("SUM OF DIGITS OF A NUMBER\n");
printf("-------------------------\n\n");
printf("Enter the number : ");
scanf("%d",&a);
final=a;
do {
n=a%10;
sum=sum+n;
a=a/10;
}
while(a!=0);
printf("\nThe sum of digits of the number %d is %d",final,sum);
printf("\n\nPRESS ANY KEY TO EXIT...");
getch();
}
PROGRAM TO FIND SUM AND AVERAGE OF GIVEN NUMBERS
PHP Code:
#include <stdio.h>
char input[1000];
int num_count;
float total, average, temp;
int main()
{
printf("FIND SUM & AVERAGE OF GIVEN NUMBERS\n");
printf("-----------------------------------\n\n\n");
printf("Enter first number (00 to quit): ");
fgets(input, sizeof(input), stdin);
sscanf(input, "%f", &temp);
num_count = 0;
total = 0.0;
average = 0.0;
while ( temp != 00.00 ) {
++num_count;
total += temp;
temp = 0;
printf("Enter next number (00 to quit): ");
fgets(input, sizeof(input), stdin);
sscanf(input, "%f", &temp);
}
average = ( total / num_count );
printf("\nYou have entered %d numbers. \n\nThe SUM of those numbers is %f. \nThe AVERAGE of those numbers is %f.\n", num_count,total, average);
printf("\n\n PRESS ANY KEY TO EXIT...");
getch();
return 0;
}
third program witch FIND LCM AND GCD OF TWO INTEGERS
PHP Code:
#include <stdio.h>
int gcd(int m,int n)
{
while( m!= n)
{
if( m > n)
m= m - n;
else
n= n - m;
}
return (m);
}
int lcm(int m,int n)
{
return( m * n / gcd (m , n));
}
main()
{
int m,n;
//int lcm(int,int);
//int gcd(int,int);
printf("\n LCM & GCD FINDER \n");
printf(" -----------------\n\n");
printf("\nEnter the first number : ");
scanf("%d", &m);
printf(" \nEnter the second number : ");
scanf("%d", &n);
printf("\n\nGCD of %d and %d is %d\n",m,n, gcd(m,n));
printf("LCM of %d and %d is %d\n",m,n, lcm(m,n));
printf("\n\nPRESS ANY KEY TO EXIT...");
getch();
}
PHP Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,z;
printf("REVERSING A NUMBER \n");
printf("------------------\n\n");
printf("Enter the number to be reversed : ");
scanf("%d",&x);
if(x<0)
{
x=x*(-1);
}
printf("\n\nThe reversed number is: ");
while(x>10)
{
y=x/10;
z=x%10;
x=y;
printf("%d",z);
}
printf("%d",x);
printf("\n\nPRESS ANY KEY TO EXIT...");
getch();
}
PHP Code:
#include<stdio.h>
void main()
{
int matrix[3][3];
int i,j,x,y,total;
int sum=0;
printf("MATRIX OPERATIONS \n");
printf("----------------- \n\n");
printf("Enter the 3x3 Matrix elements: \n");
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{ scanf("%d", &matrix[i][j]); }
}
clrscr();
printf("The matrix you entered is : \n");
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{ printf("%d ", matrix[i][j]); }
printf("\n\n");
}
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{ sum = sum + matrix[i][j]; }
printf("Sum of Row %d is : %d\n", i,sum);
sum=0;
}
printf("\n\n");
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{ sum = sum + matrix[j][i]; }
printf("Sum of Column %d is : %d\n", i,sum);
sum=0;
}
printf("\n\n");
for(i=1;i<=3;i++)
{ for(j=1;j<=3;j++)
{ total = total + matrix[i][j]; }
}
printf("Sum of all elements of the matrix is : %d\n", total);
printf("\n\nPRESS ANY KEY TO EXIT...");
getch();
exit(0);
}



