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. ...
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; ...
Program to see all ASCII value using for loop in C-language #include<stdio.h> int main() { char i; printf("All ASCII values are\n"); for(i=32;i<=127;i++) { printf("%c ",i); } } OUTPUT This program help you to print all number from 0 to 9 ,and A to Z in capital letter as well as in small later. And you also get knowledge about ASCII Value. If you like this program then you can share it and for any issues you can direct contact with me from Home Page . For regular updates you can also follow my site. Visit Homepage
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:- ...
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 cheque enter number is even or odd in c-language #include<stdio.h> int main() { int x; printf("Enter the number\n"); scanf("%d",&x); if(x%2==0) { printf("Enter number %d is even",x); } else { printf("Enter number %d is odd",x); } } OUTPUT Enter the number 17 Enter number 17 is odd Visit Homepage
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.
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]) { ...
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...
Comments
Post a Comment