Wednesday, October 3, 2018


Assignment – 3



1.
What is the importance of pointers to pointers? Explain it with an example.
CO3
2.
Explain Basics of functions and its categories.
CO3
3.
Explain all Storage classes – auto, static, extern, register.
CO3
4.
What are various Dynamic memory management techniques? What are uses of them?
CO3
5.
Define Command line arguments. Write a program on Command line arguments.
CO3


Tutorial – 5

1.
How can you implement arrays with pointer? Explain it with an example.
CO3
2.
How can you implement strings with pointer? Explain it with an example.
CO3
3.
Explain Pre-processor directives, Macros with example programs.
CO3


Tutorial – 6

1.
Define Recursion? Function for factorial of a number using recursion.
CO3
2.
Is it possible to pass arrays as parameters to a function? If yes, pass an array of elements & return minimum element in the array.
CO3
3.
What is the importance of standard library functions? List out 10 standard library functions.
CO3

NCR Using Functions


#include<stdio.h>
#include<conio.h>

int power(int x, int n);
int factorial(int n);

int ncr(int n, int r)
{
    int ncr=1,i;
    for(i=0;i<r;i++)
        ncr=ncr*(n-i);
    ncr=ncr/factorial(r);
    return ncr;
}

void main()
{
    int exp,n,r,x;

    printf("\n\n\tEnter n, r, x values: ");
    scanf("%d%d%d",&n,&r,&x);

    exp=ncr(n,r)*power(x,n)/factorial(n);

    printf("\n\n\tExp = %d\n\n",exp);
    getch();
}

int power(int x, int n)
{
    int pow=1,i;
    for(i=1;i<=n;i++)
        pow=pow*x;
    return(pow);
}

int factorial(int n)
{
    int i,fact=1;
    for(i=1;i<=n;i++)
        fact=fact*i;
    return(fact);
}