Skip to main content

Featured

Data of Employees using Structure

There is a structure called employee that holds information like employee code, name, date of joining. That is a program that creates an array of the structure and enters some data. Then ask the user to enter current date. After that Display the names of those employees whose tenure is 3 or more than 3 years according to the given current date. #include<stdio.h> #include<stdlib.h> struct emp{     int code,date;     char name[16]; }; int main() {      struct emp e[20];      int x,i,j,cdate,res;      printf("How many employee are there?");      scanf("%d",&x);      for(i=0;i<x;i++)      {          printf("Enter Employee code:");//int          scanf("%d",&e[i].code);          printf("Enter employee name:");          scanf("%s",e[i].name);          printf("Enter date of joining(yyyymmdd):");          scanf("%d",&e[i].date);      }      printf("Enter current date(yyyymmdd):")

Strong numbers in C

 C exercises: Find Strong Numbers within a range of numbers - w3resource

From given photo you can simply understand what is strong number, I've made a program that can be use to check whether input number is strong or not!

Code:

#include<stdio.h>

int main()

{

        int num, temp, rem, count, fact, sum = 0;


        printf("Enter a number--}");

        scanf("%d", &num);

        temp = num;


        while(num)

    {

        rem = num%10;

        count = 1;

        fact =1;


        while(count <= rem)

        {

        fact = fact*count;

        count++;

        }

    printf("Factorial of %d is %d\n", rem, fact);


    sum = sum +fact;

    num= num/10;

    }

    if(temp == sum)

    {

        printf("%d is a strong number\n", temp);

    }

    else

    {


        printf("%d is not a strong number\n", temp);


    }

    return 0;

}

  


imagecontainingcopyrightby w3resouce.com

Comments

Popular Posts