Posts

C Programming Algorithum

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, num2 and sum. Step 3: Read values num1 and num2. Step 4: Add num1 and num2 and assign the result to sum. sum←num1+num2 Step 5: Display sum Step 6: Stop Flow Chart Digrame           ...

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 ...