Skip to main content

Posts

Showing posts from January, 2019

WAP to read two arrays and find the union.

WAP to read two arrays and find the union in C.                                  Array 1 : 5,10,15,20,25,30 Array 2 : 10,20,45,60,70 Array 3 : 5,10,15,20,25,30,45,60,70 #include<stdio.h> #include<conio.h> void main() { int x[50],y[50],z[50],i,j,k,m,n,flag; clrscr(); /*read the array */ printf("\nEnter the value of m:"); scanf("%d",&m); for(i=0;i<m;i++) { printf("\nEnter the element :"); scanf("%d",&x[i]); } /*read the second array */  printf("\nEnter the value of n:"); scanf("%d",&n); for(j=0;j<n;j++) { printf("\nEnter the element :"); scanf("%d",&y[j]); } /*find the union*/ /*copy the first array into the third*/ k=0; for(i=0;i<m;i++) { z[k]=x[i]; k++; } /*copy only the uncommon elements of array second int...

Write a "C" program to read the value of n and find the position of an element in the array.

Write a "C" program to read the value of n and find the position of an element in the array.  Suppose the array contains the following elements , 5,10,15,20,25 and we want to search for the value , 15 , then the program will return the position 2 as the index starts with 0.  And suppose we want to search , 80 , then the program will return -1 , which is an indication that the search value is not found. #include<stdio.h> #include<conio.h> void main() { int x[50],i,n,position,sval; clrscr(); /*read the array*/ printf("\nEnter the value of n :"); scanf("%d",&n); for(i=0;i<n;i++) { printf("\nEnter the element :"); scanf("%d",&x[i]); } /*read the value you want to search */ printf("\nEnter the search value :"); scanf("%d",&sval); /*search for the value */ position=-1; for(i=0;i<n&&positi...

Read the array and find the maximum as well as the minimum elements out of an array.

WAP to read the array and find the maximum as well as the minimum elements out of an array in "C". #include<stdio.h> #include<conio.h> void main() { int x[50],i,n,max,min; printf("\nEnter the value of n:"); scanf("%d",&n); for(i=0;i<n;i++) { printf("\nEnter the element :"); scanf("%d",&x[i]); } /*find the maximum as well as minimum */ max=x[0]; min=x[0]; for(i=1;i<n;i++) { if(x[i]>max) max=x[i]; else if(x[i]<min) min=x[i]; } printf("\nMaximum = %d , Minimum = %d",max,min); getch(); } c programming language,c programming software,c programming download,c programming online,c programming examples,c programming tutorial,c programming code c programming w3schools,c++ compiler download,turbo c compiler,online c compiler,c compiler for windows,c++ compiler,online compiler online c++ compile...

Write a "C" programs to find the maximum elements out of an array

Write a "C" programs to find the maximum elements out of an array #include<stdio.h> #inclulde<conio.h> void main() { int x[50],i,n,max; clrscr(); /*read the array*/ printf("\nEnter the value of n:"); scanf("%d",&n); for(i=0;i<n;i++) { printf("\nEnter the value of element:"); scan("%d",&x[i]); } /*find the maximum element out of an array */  max=x[0]; for(i=1;i<n;i++) { if(x[i]>max) max=x[i]; } printf("\nMaximum = %d",max); getch(); } c programming language,c programming software,c programming download,c programming online,c programming examples,c programming tutorial,c programming code c programming w3schools,c++ compiler download,turbo c compiler,online c compiler,c compiler for windows,c++ compiler,online compiler online c++ compiler,gdb compiler,c programming practice questions pdf,c programming pr...

"C" program to read the array and find the sum of all the elements of the array.

Write a "C" program to read the array and find the sum of all the elements of the array. #include<stdio.h> #include<conio.h> void main() {             int x[50],i,n,sum;             clrscr();             /*read the array */             printf("\nEnter the value of n:");             scanf("%d",&n);             for(i=0;i<n;i++)             {                         printf("\nEnter the value of n:");       ...

Write a 'c' program to read and display the array

Write a 'c' program to read and display the array   #include<stdio.h> #include<conio.h> main( ) {             int x[50],i,n;             clrscr();             /*read the array */             printf("\nEnter the value of n :");             scanf("%d",&n);             for(i=0;i<n;i++)             {                         printf("\nEnter the element :");              ...

Initialization Methods of Array in C Programming languge

Initialization of Array in C (a) int x[5]={10,12,14,16,19};             x[0]=10             x[1]=12             x[2]=14             x[3]=16             x[4]=19             All the elements through which we want to initialise the array are given in the curley braces and are  separated by the comma. (b) int x[5]={10,12,14};             x[0]=10             x[1]=12             x[2]=14             and the...

Arrays in C Definition

      Arrays in C   Arrays:             An Array is a collection of elements .In the case of the array all the             elements are identified by the same array name but the different index        number or the sub-script reference.             The general form of defining the array is ,                         datatype arrayname[sizeofarray];             e.g.                         int x[5];            ...

Write a program to generate pattern using STARS

Write a program to generate the following pattern    n=4   ****  ***  **  * #include<stdio.h> #include<conio.h> main() {             int i,j,n,sp;             clrscr();             printf("\nEnter the value of n :");             scanf("%d",&n);             sp=0;             for(i=n;i>=1;i--)             {                         for(j=1;j<=sp;j++)        ...

Write a program to generate pattern using for loop STARS

Write a program to generate the following pattern  n=4   *  **  ***  **** #include<stdio.h> #include<conio.h> main() {             int i,j,n,sp;             clrscr();             printf("\nEnter the value of n :");             scanf("%d",&n);             sp=n-1;             for(i=1;i<=n;i++)             {                         for(j=1;j<=sp;j++)         ...

generate the following pattern in C 1 23 345

Write a program to generate the following pattern in C    n=4  1 23  345  4567 #include<stdio.h> #include<conio.h> main() {             int i,j,n,term=1;             clrscr();             printf("\nEnter the value of n :");             scanf("%d",&n);             for(i=1;i<=n;i++)             {                         for(j=1;j<=i;j++)                     ...

Write a program to generate pattern in C using for loop 1 23 456

Write a program to generate the following pattern in C using for loop  n=4   1  23 456 78910 #include<stdio.h> #include<conio.h> main() {             int i,j,n,term=1;             clrscr();             printf("\nEnter the value of n :");             scanf("%d",&n);             for(i=1;i<=n;i++)             {                         for(j=1;j<=i;j++)                    ...

Write a program to generate the following pattern using for loop in C

Write a program to generate the following pattern  n=4   * *** ***   *****  ***  * #include<stdio.h> #include<conio.h> main() {             int i,j,n;             clrscr();             printf("\nEnter the value of n :");             scanf("%d",&n);             for(i=n;i>=1;i--)             {                         for(j=1;j<=2*i-1;j++)                    ...

Write a program to generate the following pattern using star for loop

Write a program to generate the following pattern using star   n=4   *  ***  *****  ******* #include<stdio.h> #include<conio.h> main() {             int i,j,n;             clrscr();             printf("\nEnter the value of n :");             scanf("%d",&n);             for(i=1;i<=n;i++)             {                         for(j=1;j<=2*i-1;j++)                  ...

WAP to read the value of n and display the following pattern

 WAP to read the value of n and display the following pattern   n=4   1           0*10+1=0+1=1 11         1*10+1=10+1=11  111       11*10+1=110+1=111  1111    111*10+1=1110+1=1111 #include<stdio.h> #include<conio.h> main() {             int i,n,term;             clrscr();             printf("\nEnter the value of n :");             scanf("%d",&n);             term=0;             for(i=1;i<=n;i++)             {    ...

Write a 'c' program to read the number and find the reverse

Write a 'c' program to read the number and find the reverse  num = 435   rev = 534 #include<stdio.h> #include<conio.h> main( ) {             int num,rev;             clrscr();             printf("\nEnter the number :");             scanf("%d",&num);             for(rev=0;num!=0;num=num/10)             {                         rev=rev*10+num%10;             }           ...

WAP to generate following pattern in C

          WAP to generate the following pattern       n = 4      1       i=1   00       i=2 111      i=3  0000    i=4 #include<stdio.h> #include<conio.h> main( ) {             int i,j,n,term;             clrscr();             printf("\nEnter the value of n:");             scanf("%d",&n);             for(i=1;i<=n;i++)             {                      ...