Posts

Program to show present time and date in C-language

Program to show present time and date in C-language. #include <stdio.h> #include <string.h> int main() {   char time[10];   char date[12];   strcpy(time, __TIME__);   strcpy(date, __DATE__);   printf("%s %s\n", time, date);      return 0; } OUTPUT 08:17:09 May 25 2020 The above time and date change according to you when you run the program,So it show different time. If you like this program you can share comments and follow.

Binary searching in C-language

Program to search an element using binary search. #include<stdio.h> int main() {     int i,a[10],n,b,c=0,l,f,mid;     printf("Enter the size limit maximum is 10\n");     scanf("%d",&n);     printf("Enter the array element\n");     for(i=0;i<n;i++)     {         scanf("%d",&a[i]);     }     printf("Enter the element to be searched\n");     scanf("%d",&b);     f=0;     l=n-1;     while(f<=l)     {         mid=(f+l)/2;         if(b<a[mid])         {             l=mid-1;         }         if(b>a[mid])         {             f=mid+1;         }         else if(b==a[mid])         {             c=1;             break;         }     }     if(c==0)     {         printf("Element not found");     }     else     {         printf("Element found at %d position",mid+1);     }     } OUTPUT Enter the size limit maximum is 10 4 Enter array element 4 6 3 9 Enter the element to be searched 6 Element

Linear search in C-language

Program to search an element in an array and position in that element and no duplicate element exit in C-language #include<stdio.h> int main() {     int i,a[10],n,b,c=0;     printf("Enter the size limit maximum is 10\n");     scanf("%d",&n);     printf("Enter the array element\n");     for(i=0;i<n;i++)     {         scanf("%d",&a[i]);     }     printf("Enter the element to be searched\n");     scanf("%d",&b);     for(i=0;i<n;i++)     {         if(b==a[i])         {             c++;             printf("Element found at position %d\n",i+1);             break;         }     }     if(c==0)     {         printf("Element not found");     }     } OUTPUT Enter the size limit maximum is 10 4 Enter the array element 8 7 8 56 Enter the element to be searched 8 Element found at position 1

Linear search in C-language

Program to search an element in an array also print the occurrence and position of that elements in C-language. #include<stdio.h> int main() {     int i,a[10],n,b,c=0;     printf("Enter the size limit maximum is 10\n");     scanf("%d",&n);     printf("Enter the array element\n");     for(i=0;i<n;i++)     {         scanf("%d",&a[i]);     }     printf("Enter the element to be searched\n");     scanf("%d",&b);     for(i=0;i<n;i++)     {         if(b==a[i])         {             c++;             printf("Element found at position %d\n",i+1);         }     }     if(c==0)     {         printf("Element not found");     }     else         {         printf("Element is found %d times",c);     }     } OUTPUT Enter the size limit maximum is 10 4 Enter the array element 6 4 6 7 Enter element to be searched 6 Element found at position 1 Element found at position 3 Element is found 2 times

Linear search in C-language

Program to search an element from an array also print the occurrence of that particular element in C-language. #include<stdio.h> int main() {     int i,a[10],n,b,c=0;     printf("Enter the size limit maximum is 10\n");     scanf("%d",&n);     printf("Enter the array element\n");     for(i=0;i<n;i++)     {         scanf("%d",&a[i]);     }     printf("Enter the element to be searched\n");     scanf("%d",&b);     for(i=0;i<n;i++)     {         if(b==a[i])         {             c++;         }     }     if(c==0)     {         printf("Element not found");     }     else         {         printf("Element is found %d times",c);     }     } OUTPUT Enter the size limit maximum is 10 4 Enter the array element 3 2 3 8 Enter the array element to be searched 3 Element is found 2 times

Program to reverse one array into other array in C-language

Program to reverse one array into other array in C-language #include<stdio.h> int main() {     int i,a[10],n,b[10];     printf("Enter the size limit maximum is 10\n");     scanf("%d",&n);     printf("Enter the array element\n");     for(i=0;i<n;i++)     {         scanf("%d",&a[i]);     }     for(i=0;i<n;i++)     {         b[n-1-i]=a[i];     }     printf("Reverse of array is\n");     for(i=0;i<n;i++)     {       printf("%d ",b[i]);     }     } OUTPUT Enter the size limit maximum is 10 4 Enter the array element 1 2 3 4 Reverse of array element is 4 3 2 1

Program to find the sum of two array into the third in C-language

Program to find the sum of two array into the third in C-language #include<stdio.h> int main() {     int i,a[10],n,b[10],c[10];     printf("Enter the size limit maximum is 10\n");     scanf("%d",&n);     printf("Enter the First array element\n");     for(i=0;i<n;i++)     {         scanf("%d",&a[i]);     }     printf("Enter the second array element\n");   for(i=0;i<n;i++)     {         scanf("%d",&b[i]);     }     printf("Sum of array is\n");     for(i=0;i<n;i++)     {         c[i]=a[i]+b[i];         printf("%d ",c[i]);     }          } OUTPUT Enter the size limit maximum is 10 4 Enter the First array element 12 3 4 6 Enter the second array element 6 5 4 3 Sum of array is 18 8 8 9

Program to find maximum and minimum elements in an array in C-language

Program to find maximum and minimum elements in an array in C-language #include<stdio.h> int main() {     int i,a[10],n,min,max=0;     printf("Enter the size limit maximum is 10\n");     scanf("%d",&n);     printf("Enter the array element\n");     for(i=0;i<n;i++)     {         scanf("%d",&a[i]);     }     min=a[0];     for(i=0;i<n;i++)     {        if(max<a[i])         {             max=a[i];         }         else if(min>a[i])         {             min=a[i];         }     }     printf("Maximum is  %d minimum is %d",max,min);     } OUTPUT Enter the size limit maximum is 10 4 Enter the array element 6 9 0 1 Maximum is 9 minimum is 0

Program to find the sum of all n elements in an array in C-language

Program to find the sum of all n elements in an array in C-language #include<stdio.h> int main() {     int i,a[10],n,sum=0;     printf("Enter the size limit maximum is 10\n");     scanf("%d",&n);     printf("Enter the array element\n");     for(i=0;i<n;i++)     {         scanf("%d",&a[i]);     }     printf(" Sum of Array element is\n");     for(i=0;i<n;i++)     {         sum=sum+a[i];     }     printf("  %d ",sum);      } OUTPUT Enter the size limit maximum is 10 4 Enter the array element 1 4 3 2 Sum of Array element is 10

Program to input an array elements and then display the same array in C-language

Program to input an array elements and then display the same array in C-language #include<stdio.h> int main() {     int i,a[10],n;     printf("Enter the size limit maximum is 10\n");     scanf("%d",&n);     printf("Enter the array element\n");     for(i=0;i<n;i++)     {         scanf("%d",&a[i]);     }     printf("Array element are\n");     for(i=0;i<n;i++)     {         printf("%d ",a[i]);     } } OUTPUT Enter the size limit maximum is 10 4 Enter the array element 4 7 8 0 Array element are 4 7 8 0

Creative Pattern of Rhino in C-language

Image
Creative Pattern of Rhino in C-language #include<stdio.h> int main() {     printf("\t\t                               ,-.             __\n");     printf("\t\t                             ,\'   `---.___.---\'  `.\n");     printf("\t\t                           ,\'   ,-                 `-._\n");     printf("\t\t                         ,\'    /                       \\\n");     printf("\t\t                      ,\\/     /                        \\\\\n");     printf("\t\t                  )`._)>)     |                         \\\\\n");     printf("\t\t                  `>,\'    _   \\                  /       |\\\n");     printf("\t\t                    )      \\   |   |            |        |\\\\\n");     printf("\t\t           .   ,   /        \\  |    `.          |        | ))\n");     printf("\t\t           \\`. \\`-\'          )-|      `.   

Creative pattern of butterfly in C-language

Image
Creative pattern of butterfly in C-language #include<stdio.h> main() {     printf("\t\t\t\t                `         \'\n");     printf("\t\t\t\t;,,,             `       \'             ,,,;\n");     printf("\t\t\t\t`YES8888bo.       :     :       .od8888YES\'\n");     printf("\t\t\t\t  888IO8DO88b.     :   :     .d8888I8DO88\n");     printf("\t\t\t\t  8LOVEY\'  `Y8b.   `   \'   .d8Y\'  `YLOVE8\n");     printf("\t\t\t\t jTHEE!  .db.  Yb. \'   \' .dY  .db.  8THEE!\n");     printf("\t\t\t\t   `888  Y88Y    `b ( ) d\'    Y88Y  888\'\n");     printf("\t\t\t\t    8MYb  \'\"        ,\',        \"\'  dMY8\n");     printf("\t\t\t\t   j8prECIOUSgf\"\'   \':'   `\"?g8prECIOUSk\n");     printf("\t\t\t\t     \'Y\'   .8\'     d\' \'b     \'8.   \'Y\'\n"

Variable & Datatype for C-programming

Variable & Datatype for C-programming                                   5 Variable:- Whose value change is known as variable.You can use some specific variable. Ex:-a,b,c        A,B,C        a1,b2 But 1a,2b, space, special character are  not allowed. Underscore is allowed. Datatype:- Before declaration variable you need to define the type of variable i.e. integer, character, float etc Variable declaration:- You can define a variable in following way. Syntax:- datatype  variablename; Eg:-int x;        int a;        float q; Variable intialization:- In this step you have to give the value of variable. During character intialization write character within the '   ' Eg:-int x=1; or int x; x=1;       Datatype:- Datatype definition the nature of variable. It is mainly three types. 1.Integer 2.Character 3.Float 1.Integer datatype:- It represent integer value. And expressed as %d; Data Type      Size in bytes

Syntax of C-language

      Syntax of C-programming                                4. A C program is divided into different sections. There are six main sections to a basic c program.  The six sections are, Documentation Link Definition Global Declarations Main functions Subprograms 1. Documentation:- The documentation section is the part of the program where the programmer gives the details associated with the program. He usually gives the name of the program, the details of the author and other details like the time of coding and description. It gives anyone reading the code the overview of the code. 2.Link Section:- This part of the code is used to declare all the header files that will be used in the program. This leads to the compiler being told to link the header files to the system libraries. 3.Definition Section:- In this section, we define different constants. The keyword define is used in this part. 4.Global Declaration Section:- This part of th

Errors in C-language

                                      3. Errors in C-language Syntax error Logical error Math error Run time error Linker error Semantic error 1.Syntax error:-                                If any changes made in the predefined format of a c-language then the error is called  syntax error. Eg:- If semicolon missing or printf,scanf or other keyword are missing comes under syntax error. 2.Logical error:-                                   This error occurs when the user gets and an unaccepted output. Eg:- If the program is expected to give the output in real number but we are getting the output in integer. 3.Math error:-                             This error occurs because of the illegal input. Eg:- An number divided by zero is illegal modulus  operator  will not work for floating value. 4.Run time error:-                                    An error occurs at a time of exception is known as run time error. Eg:- In the syntax of scanf & i

Language Translator of C-language

                                       2.               Language Translator 1. Assembler 2. Compiler 3. Interpreter 4. Linker 5. Loader 1.Assembler:-   In computer science, assembler is a program which convert assembly level language into machine level language, because computer understand binary language.                          Machine code                                     ⬆️                                     ⬆️                               Assembler                                     ⬆️                                     ⬆️                    Assembly Level language 2. Compiler:-  Compiler turns the high level language to binary language or machine code at only one time is known as compiler.  3.Interpreter:- An  is also a program like compiler it convert assembly language to binary language but an interpreter goes one line of  a code a at time. 4.Linker:-   linker is used to link multiple obj files to create an executable file

Introduction of C-language.

Image
              Introduction of C-language                                           1. C-language was developed by  Dennis Ritchie  . In the year  1972  in  Bell Laboratory  in  USA  . C language suitable for system programmings ,it was mainly developed for  UNIX operating system . Dennis Ritchie (1941-2011) Books:-   The C Programming languages Dennis Ritchie also known as father of C-language.                         Use of C-language  ๐Ÿ‘‰๐ŸฟOperating system.  ๐Ÿ‘‰๐ŸฟLanguage Compiler.  ๐Ÿ‘‰๐ŸฟText editor.  ๐Ÿ‘‰๐ŸฟModern Program.  ๐Ÿ‘‰๐ŸฟDatabase.  ๐Ÿ‘‰๐ŸฟLanguage interpreter.  ๐Ÿ‘‰๐ŸฟMobile & desktop application.  ๐Ÿ‘‰๐Ÿฟ Gaming & Animation.                Features of C-language ๐Ÿ‘‰๐Ÿฟ Compiler based. ๐Ÿ‘‰๐ŸฟCase sensitive. ๐Ÿ‘‰๐Ÿฟ Simple & Powerful. ๐Ÿ‘‰๐Ÿฟ Syntax based. ๐Ÿ‘‰๐Ÿฟ Structure oriented. ๐Ÿ‘‰๐Ÿฟ Middle level. After reading this article you will be able to know about C-language, features,use of c-language,and more things related to C-l

Popular posts

Creative pattern of butterfly in C-language

Program to show present time and date in C-language

Introduction of C-language.

Program to cheque enter number is a perfect number or not using if else in C-language

Program to cheque four digits number is palindrome or not in C-language

Program to print the cube of a number in c-language

Simple Hello world program in c- language