Posts

Showing posts from December, 2020

Create a christmas tree use C

Image
 Create a christmas tree use C language very simple step. #include<stdio.h> int main() {     int i,j,k,s=50,c; for(i=1;i<=5;i++)   //first loop { for(k=1;k<=s;k++) { printf(" ");     }   s=s-1;   for(j=1;j<=i;j++)     {     printf("*");         }         //printf("\n");         for(c=1;c<=i;c++)         {         printf("*"); } printf("\n");     }     int i1,j1,k1,s1=49,c1;   //secand loop     for(i1=2;i1<=6;i1++)     {     for(k1=1;k1<=s1;k1++)     {     printf(" "); } s1=s1-1; for(j1=1;j1<=i1;j1++) { printf("*"); } for(c1=1;c1<=i1;c1++) { printf("*"); } printf("\n"); } int i2,j2,k2,s2=48,c2;     //third loop ...

Swap two number with customer choice

Image
 Swap two number with customer choice in C language. #include<stdio.h> void swap(int,int); int main()  {     int a,b;       printf("Enter first number: ");       scanf("%d", &a);       printf("Enter second number: ");       scanf("%d", &b);       swap(a,b); } void swap(a,b) {        int temp = a;       a = b;       b = temp;       printf("After swapping, firstNumber = %d\n", a);       printf("After swapping, secondNumber = %d", b); } Output program Thank You.