Write A C Program To Add Any 10 Numbers Given by The User
Write A C Program To Add Any 10 Numbers Given by The User
#include<stdio.h>
#include<conio.h>
void main()
{ int i,n,sum=0;
Output:
2. Write a C program to check whether a number is even or odd
#include <stdio.h>
void main()
{
int number;
}
Output:
3. Write a C program to reverse a number
#include <stdio.h>
void main()
{
int n, reverse = 0;
while (n > 0)
{
reverse = reverse * 10;
reverse = reverse + n%10;
n = n/10;
}
Output:
4. Write a C Program to Find Factorial of a Number
#include <stdio.h>
void main()
{
int n, i;
unsigned long factorial = 1;
else
{
for(i=1; i<=n; ++i)
{
factorial = factorial*i;
}
printf("Factorial of %d = %llu", n, factorial);
}
Output:
5. Write a C program to add two matrix
#include <stdio.h>
void main()
{
int m, n, c, d, first[10][10], second[10][10], sum[10][10];
#include <stdio.h>
#include <conio.h>
getch();
while(n != 0) {
remainder = n%2;
n = n/2;
binary= binary + (remainder*i);
i = i*10;
}
return binary;
}
Output:
7. Write a Program to read age of 10 persons and display only those persons whose between 50
and 60
#include<stdio.h>
#include<conio.h>
void main()
{
int i,age[10],count=0;
for (i=0;i<10;i++)
{
printf("\nEnter age of %d persons :: ",i);
scanf("%d",&age[i]);
}
for (i=0;i<10;i++)
{
if(age[i]>50 && age[i] < 60)
count++;
else
continue;
}
void main()
{
double base, exponent, result;
Output:
9. Write a C program to swap two numbers
#include <stdio.h>
void main()
{
int x, y, temp;
temp = x;
x = y;
y = temp;
Output:
10. Write a C program to add any three numbers using given by the user using pointer concept
#include <stdio.h>
void main()
{
int first, second,third, *p, *q, *r,sum;
p = &first;
q = &second;
r=&third;
Output: