Posts

Welcome to Cbasic

Image
Do you face problems in C language? Do you want to be an expert in C?  A website which not only teaches you coding but also shows you hidden secrets behind coding, a website made for the students by the students. Here you will get solution of everything which helps you to be an expert in C. Note:  1. Specially designed as per requirements of   Chitkara University students. 2. Practice test with solutions will also be uploaded time to time. 3. Lab experiment solutions will also be uploaded. This post is being published to ask what you need. Fill this form for your suggestion and feedback:   Click here to fill form You can also subscribe to our website to get latest updates. Important: After some time a big update will be there in which all courses assignment solutions and experiments will be in this website.

Code for ascending order(using bubble sort)

Image
Code for ascending order(using bubble sort) #include<stdio.h> #include<conio.h> void main() {     int i,a[10],j=i+1,c;     printf("Enter 5 elements");     for(i=0;i<5;i++)     {         scanf("%d",&a[i]);     }     printf("Ascending order=");     for(i=0;i<5;i++)     {         for(j=i;j<5;j++)         {             if(a[i]>a[j])             {                 c=a[i];                 a[i]=a[j];                 a[j]=c;             }         }         printf("%d",a[i]);     }     getch();     } ...

Code to search location of element in array

Image
Code to search location of element in array #include<stdio.h> #include<conio.h> void main() {     int i,a[5],b,c=0;     printf("Enter 3 elements");     for(i=0;i<3;i++)     {         scanf("%d",&a[i]);     }     printf("Enter number that you want to search");     scanf("%d",&b);     for(i=0;i<3;i++)     {      if(b==a[i])      {       c=1;       printf("Element found at location(location will start from 0)= %d",i);      }     }     if(c==0)     {         printf("Element not found");     }     getch();     } Output

Code for product in array

Image
Code for product in array #include<stdio.h> #include<conio.h> void main() {     int i,a[5],m=1;     printf("Enter 3 elements");     for(i=0;i<3;i++)     {         scanf("%d",&a[i]);     }     for(i=0;i<3;i++)     {         m=m*a[i];     }     printf("Product=%d",m);     getch();     } Output

Code for sum in array

Image
Code for sum in array #include<stdio.h> #include<conio.h> void main() {     int i,a[5],s=0;     printf("Enter 3 elements");     for(i=0;i<3;i++)     {         scanf("%d",&a[i]);     }     for(i=0;i<3;i++)     {         s=s+a[i];     }     printf("Sum=%d",s);     getch();     } Output

Code for array display

Image
Code for array display #include<stdio.h> #include<conio.h> void main() {     int i,a[5];     printf("Enter 3 elements");     for(i=0;i<3;i++)     {         scanf("%d",&a[i]);     }     printf("Array is ");     for(i=0;i<3;i++)     {         printf("%d",a[i]);     }     getch();     } Output

Code for pattern 9

Image
Code for pattern 9     *   *A*  *A*A* *A*A*A* #include<stdio.h> #include<conio.h> void main() {     int i,j,k;     for(i=1;i<=4;i++)     {         for(j=3;j>=i;j--)         {             {             printf(" ");             }         }         for(k=1;k<2*i;k++)         {             if(k%2==0)             {                 printf("A");             }             else             {                 printf("*");          ...