Posts

Showing posts from September, 2017

C Programming Constant

Image
Constant Constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals. Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. There are enumeration constants as well. Define Constant Constant in C means the content whose value does not change at the time of execution of a program. Example: #include >stdio.h < int main() { printf("Hello\tWorld\n\n"); return 0; } Constant Digram Types Of Constant 1. Integer constants 2. Floating-point constants 3. Character constants 4. Escape Sequences 5. String constants 6. Enumeration constants 1.Integer constants : An integer constant is a numeric constant (associated with number) without any fractional or exponential part. There are three types of integer constants in C programming: decimal constant(base 10) octal constant(base...

C Programming input output

C programming Input & Output This tutorial focuses on two in-built functions printf() and scanf() to perform I/O task in C programming. Also, you will learn to write a valid program in C. Two commonly used functions for I/O (Input/Output) are printf() and scanf(). The scanf() function reads formatted input from standard input (keyboard) whereas the Example Of Input & Output : #include <stdio.h> //This is needed to run printf() function. int main() { printf("C Programming");//displays the content inside quotation return 0; } Output: C Programming The Standard Files : C programming treats all the devices as files. So devices such as the display are addressed in the same way as files and the following three files are automatically opened when a program executes to provide access to the keyboard and screen. The scanf() and printf() Functions : The int scanf(const char *format, ...) function reads the input from the standard ...

C Function

C Function C functions are basic building blocks in a program. All C programs are written using functions to improve re-usability, understandability and to keep track on them. You can learn below concepts of C functions in this section in detail. 1. WHAT IS C FUNCTION? A large C program is divided into basic building blocks called C function. C function contains set of instructions enclosed by “{ }” which performs specific operation in a C program. Actually, Collection of these functions 2. FUNCTION DECLARATION, FUNCTION CALL AND FUNCTION DEFINITION: function definition function call function declaration Example : #include lt;stdio.h gt; function prototype, also called function declaration float square ( float x ); // main function, program starts from here int main( ) { float m, n ; printf ( "\nEnter some number for finding square \n"); scanf ( "%f", &m ) ; // function...

C Union

C Union A union is a special data type available in C that allows to store different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time. Unions provide an efficient way of using the same memory location for multiple-purpose. Union Defination: To define a union, you must use the union statement in the same way as you did while defining a structure. The union statement defines a new data type with more than one member for your program. The format of the union Advantages Of Unio 1.It occupies less memory because it occupies the memory of largest member only. Disadvantages It can store data in one member only. Syntax Union : union union_name { data_type member1; data_type member2; . . data_type memeberN; }; Example : #include <stdio.h> #include <string.h> union employee { int id; char name[50]; }e1; //declari...

Pointer In C

               Pointer In C Pointers in C language is a variable that stores/points the address of another variable. A Pointer in C is used to allocate memory dynamically /p> i.e. at run time. The pointer variable might be belonging to /p> any of the data type such as int, float, char, double, short etc /p> Normal variable stores the value whereas pointer variable stores the address of the variable. /p> The content of the C pointer always be a whole number i.e. address. /p> Always C pointer is initialized to null, i.e. int *p = null./p> The value of null pointer is 0. Example: #include < stdio.h > int main() { int *ptr, q; q = 50; /* address of q is assigned to ptr */ ptr = &q; /* display q's value using ptr variable */ printf("%d", *ptr); return 0; } << PREVIEW >> << NEXT >>

c Programming loops

C Looping statment. You may encounter situations, when a block of code needs to be executed several number of times. In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on Programming languages provide various control structures that allow for more complicated execution paths. A loop statement allows us to execute a statement or group of statements Types Of Loop 1. while loop 2.Do while loop 3.for loop 1.while loop : In while loop First check the condition if condition is true then control goes inside the loop body other wise goes outside the body. while loop will be repeats in clock wise direction. Syntax: Assignment; while(condition) { Statements; ...... Increment/decrements (++ or --); } Example: #include <stdio.h> #include <conio.h> void main() { int i; clrscr(); i=1; while(i<5) { printf("\n%d",i); i++; } getch(); } Output: 1 2 3 ...

C Programming Branching Statment

Branching Statment The C language programs follows a sequential form of execution of statements. Many times it is required to alter the flow of sequence of instructions. C language provides statements that can alter the flow of a sequence of instructions. These statements are called as control statements. To jump from one part of the program to another,these statements help. The control transfer may be unconditional or conditional. Branching Statemnt are of following categories: Types Of branching Statemnt 1. If Statement 2. If else Statement 3. Nested if Statement 4. Switch Statement 5.if elseif...if 1. If Statement If the Boolean expression evaluates to true, then the block of code inside the 'if' statement will be executed. If the Boolean expression evaluates to false, then the first set of code after the end of the 'if' statement (after the closing curly brace) will be executed. Syntax: if(condition) statement; Example: ...

Array Of C Programming

Array Of C Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables o the same type. Types Of Array : 1.One Diamational Array 2.Two Dimensional Array 3.Multi Diamational Array Declaration Array To declare an array in C, a programmer specifies the type of the elements and the number of elements required by an array as follows − type arrayName [ arraySize ]; 1.Single Dimensional Array : Single or One Dimensional array is used to represent and store data in a linear form. Array having only one subscript variable is called One-Dimensional array It is also called as Single Dimensional Array or Linear Array. Syntax: [size]; Example : int iarr[3] = {2, 3, 4}; char carr[20] = "c4learn" ; float farr[3] = {12.5,13.5,14.5} ; 2.Two Dimensional Array : The...

C Programming Keyword

C Keyword Keywords are predefined, reserved words used in programming that have special meanings to the compiler. Keywords are part of the syntax and they cannot be used as an identifier. For example: int money; 1.Keywords are those words whose meaning is already defined by Compiler 2.Cannot be used as Variable Name 3.There are 32 Keywords in C 4.C Keywords are also called as Reserved words . 32 Keywords in C Programming Language auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if static while Identifiers In C language identifiers are the names given to variables, constants, functions and user-define data. These identifier are defined against a set of rules.                                  <<   PREVIOUS >> ...

Operators In C Progreamming

                      Operators In C An operator is a symbol which operates on a value or a variable. For example: + is an operator to perform addition. C programming has wide range of operators to perform various operations. For better understanding of operators, these operators can be classified as: Types Of Operators 1.Arithmetic Operators 2.Increment and Decrement Operators 3. Assignment Operators 4.Relational Operators 5.Logical Operators 6.Bitwise Operators 7.Conditional Operators 8.Special Operators 1.Arithmetic Operators : An arithmetic operator performs mathematical operations such as addition, subtraction and multiplication on numerical values (constants and variables). Example: #include <stdio.h> #include <conio.h> int main() { int a = 9,b = 4, c; c = a+b; printf("a+b = %d \n",c); c = a-b; printf("a-b = %d \n",c); c = a*b; printf("a*b = ...

C Programming Hello Word Example

Image
Hello word Example Introducation C C hello world program: c programming language code to print hello world. This program prints hello world, printf library function is used to display text on screen, '\n' places cursor on the beginning of next line, stdio.h header file contains declaration of printf function. The code will work on all operating systems may be its Linux, Mac or any other and compilers. To learn a programming language you must start writing programs in it and may be your first c code while learning programming. We may store "hello world" in a character array as a string constant and then print it. A simple C program to display "Hello, World!" on the screen. Since, it's a very simple program, it is often used to illustrate the syntax of a programming language. To understand this example, you should have the knowledge of following C programming Define C C is a high-level and general-purpose programming language th...

Algorithum Of C Programming

Image
                                                                  Algorithum In C what is algorithum So, what is a programming algorithm? You can think of a programming algorithm as a recipe that describes the exact steps needed for the computer to solve a problem or reach a goal. We've all seen food recipes - they list the ingredients needed and a set of steps for how to make the described meal. Well, an algorithm is just like that. In computer lingo, the word for a recipe is a procedure, and the ingredients are called inputs. Your computer looks at your procedure, follows it to the letter, and you get to see the results, which are called outputs. A programming algorithm describes how to do something, and your computer will do it exactly that Algorithum Step Step 1: Start Step 2: Declare variables num1,...

C Programming History

History Of C C is a general-purpose language which has been closely associated with the UNIX operating system for which it was developed - since the system and most of the programs that run it are written in C. Many of the important ideas of C stem from the language BCPL, developed by Martin Richards. The influence of BCPL on C proceeded indirectly through the language B, which was written by Ken Thompson in 1970 at Bell Labs, for the first UNIX system on a DEC PDP-7. BCPL and B are "type less" languages whereas C provides a variety of data types. In 1972 Dennis Ritchie at Bell Labs writes C and in 1978 the publication of The C Programming Language by Kernighan & Ritchie caused a revolution in the computing world. In 1983, the American National Standards Institute (ANSI) established a committee to provide a modern, comprehensive definition of C. The resulting definition, the ANSI standard, or "ANSI C", was completed late 1988. A Rough Guide to Pro...