Function in C


Write a program to show the advantage of using function in a program

Source Code:

৪টি মন্তব্য:

  1. #include
    #include
    int reverse_check(int n)
    {
    int rev,temp=0,a=10;
    while(n>0)
    {
    rev=n%a;
    n=n/a;
    temp=temp*a+rev;
    }
    return(temp);
    }
    main()
    {
    int n;
    printf("\nEnter the number: ");
    scanf("%d",&n);
    if(reverse_check(n)==n)
    printf("\nThe given number is a palindrome\n");
    else
    printf("\nthe given number is not a palindrome\n");
    }

    উত্তরমুছুন
  2. #include"stdio.h"
    int a,b,c;
    addnum(a,b){
    c=a+b;
    return c;
    }
    main(){
    start:;
    int d,e;
    scanf("%d",&d);
    scanf("%d",&e);
    printf("The addition is : %d \n",addnum(d,e));

    goto start;
    }

    উত্তরমুছুন
  3. #include
    addnum(int a,int b)
    {
    a+=b;
    return a;
    }
    int main()
    {
    int x,y;
    printf("Enter the value of A\n");
    scanf ("%d",&x);
    printf("Enter the value of B\n");
    scanf ("%d",&y);
    addnum(x,y);
    printf("The result is\n");
    printf ("%d",addnum(x,y));
    return 0;
    }

    উত্তরমুছুন
  4. #include
    addnum(int a,int b)
    {
    a+=b;
    return a;
    }
    int main()
    {
    int x,y;
    printf("Enter the value of A\n");
    scanf ("%d",&x);
    printf("Enter the value of B\n");
    scanf ("%d",&y);
    addnum(x,y);
    printf("The result is\n");
    printf ("%d",addnum(x,y));
    return 0;
    }

    উত্তরমুছুন