31 January 2022

Call By Reference

 #include<stdio.h>

int swap(int *a, int *b);

int main()
{
    int x = 4, y = 8;
    printf("The value of x and y before swap is : %d and %d\n", x,y);
    swap(&x,&y);
    printf("The value of x and y before swap is : %d and %d\n", x,y);

return 0;
}
int swap(int *a, int *b){
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}

OUT PUT--->

The value of x and y before swap is : 4 and 8 The value of x and y before swap is : 8 and 4


Call By Value

 #include<stdio.h>

int sum(int a, int b);
 
int main()
{
    int a=99,b=12;
    printf("The value of 99 + 12 is: %d", sum(a,b));
 
return 0;
}
int sum(int a, int b){
    return a+b;

}

ANS--->
The value of 99 + 12 is: 111


30 January 2022

Print Pattern

 

#include<stdio.h>


int main(){
    int n=5;
    for(int i=1 ; i<=n; i++){
        for(int j=1; j<=(2*i-1); j++){
            printf("*");
        }

        printf("\n");
    }

return 0;
}


ANS--->

*
*** ***** ******* *********



Pyramid - Pattern

 #include<stdio.h>

int main(){
   
    int n=3;
    for(int i=1 ; i<=n; i++){
        for(int j=1; j<=(n-i); j++){
            printf(" ");
        }
        for(int k=1; k<=(2*i-1); k++){
            printf("*");
        }

        printf("\n");
    }

return 0;
}



ANS----->

*
*** *****

19 January 2022

To Find Simple Interest

 # include<stdio.h>


int main()
{
   int principal = 100, rate= 6, year= 1;
   int simpleInterest= (principal*rate*year)/100;

   printf("The value of simple iterest is: %d\n", simpleInterest);


    return 0;
}

Addition Program

 # include<stdio.h>


int main()
{
   
    int a = 4;
    int b = 16;

    printf ("The Addition Of a and b is %d \n", a+b);

    return 0;
}