Showing posts with label Find. Show all posts
Showing posts with label Find. Show all posts

Find out the perfect number using c program

Write a C Program to Find out the perfect number using c program?


#include<stdio.h>
int main(){
  int n,i=1,sum=0;
  printf("\nEnter a number:-");
  scanf("%d",&n);
  while(i<n){
      if(n%i==0)
           sum=sum+i;
          i++;
  }
  if(sum==n)
      printf("\nThe no %d is a perfect number",i);
  else
      printf("\nThe no %d is not a perfect number",i);
  return 0;
}

Find g.c.d of two number using c program.

How To Find g.c.d of two number using c program.


#include<stdio.h>
int main(){
int n1,n2;
printf("\nEnter two numbers:");
scanf("%d %d",&n1,&n2);
while(n1!=n2){
if(n1>=n2-1)
n1=n1-n2;
else
n2=n2-n1;
}
printf("\nGCD=%d",n1);
return 0;
}

Write a c program to find out NCR factor of given number

How to Write a c program to find out NCR factor of given number in C Programming ?


#include<stdio.h>
int main(){
  int n,r,ncr;
  printf("Enter any two numbers->");
  scanf("%d %d",&n,&r);
  ncr=fact(n)/(fact(r)*fact(n-r));
  printf("The NCR factor of %d and %d is %d",n,r,ncr);
  return 0;
}
 int fact(int n){
  int i=1;
  while(n!=0){
      i=i*n;
      n--;
  }
  return i;
 }

How to Write a C program to find maximum between two numbers ?

Write a C program to find maximum between two numbers.



  1. /*Write a C program to find maximum between two numbers */
  2. #include <stdio.h>
  3. int main ()
  4. {
  5.     int a,b;
  6.     printf("Find the maximum between two number: ");
  7.     scanf("%d %d", &a, &b);
  8.     if ( a < b ){
  9.         printf("Minimum Number:%d\n",a);
  10.     }
  11.     if ( a > b ){
  12.         printf("Maximum Number%d\n",b);
  13.     }
  14.     return 0;
  15. }

Write a C program to find maximum between three numbers ?

Write a C program to find maximum between three numbers.

  1. /*Write a C program to find maximum between three numbers */
  2. #include<stdio.h>
  3. int main ()
  4. {
  5.     int a, b, c, max;
  6.     printf("find maximum between three numbers: ");
  7.     scanf("%d %d %d", &a, &b, &c);
  8.     if( a > b){
  9.         max = a;
  10.     }
  11.     if( b > a){
  12.         max = b;
  13.     }
  14.     if( b > c){
  15.         max = b;
  16.     }
  17.     if( c > a){
  18.         max = c;
  19.     }
  20.    if( a > c ){
  21.        max = a;
  22.    }
  23.    if ( c > b){
  24.     max = c;
  25.    }
  26.    printf("The maximum number is: %d\n", max);
  27.     return 0;
  28. }

C or C++ program to read marks of 4 subjects and find how many students are pass and fail with division

Write a C or C++ program to read marks of 4 subjects and find how many students are pass and fail with division.

This program to read marks of 4 subjects and find how many students are pass and fail with division.

To read marks of 4 subjects and find out how many students fall under the following categories:

a) avg<45 - Fail
b) 45 <= avg <55- Third Division
c) 55<= avg <60 - Second Division
d) 60<= avg <75 - First Division
e) avg >=75 - Distinction

Solution For C Program: