Skip to main content

Posts

What is Array

  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 of the same type. Instead of declaring individual variables, such as number0, number1, ..., and number99, you declare one array variable such as numbers and use numbers[0], numbers[1], and ..., numbers[99] to represent individual variables. A specific element in an array is accessed by an index. All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element. How to make picture puzzle using JavaScript Declaring Arrays 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 ]; This is called a  single-dimensional  array. The  arraySize  must be an integer constant
Recent posts

Loops in C programming with example

Loops in C programming with example A loop is used for executing a block of statements repeatedly until a given condition returns false. Example of For loop #include <stdio.h> int main () { int i ; for ( i = 1 ; i <= 3 ; i ++) { printf ( "%d\n" , i ); } return 0 ; } Output: 1 2 3 Nested For Loop in C Nesting of loop is also possible. Lets take an example to understand this: #include <stdio.h> int main () { for ( int i = 0 ; i < 2 ; i ++) { for ( int j = 0 ; j < 4 ; j ++) { printf ( "%d, %d\n" , i , j ); } } return 0 ; } Output: 0 , 0 0 , 1 0 , 2 0 , 3 1 , 0 1 , 1 1 , 2 1 , 3 Example of while loop #include <stdio.h> int main () { int count = 1 ; while ( count <= 4 ) { printf ( "%d " , count ); count ++; } return 0 ; } Output: 1 2 3 4 Example of while loop using logical operator In this example

Loop In C Language

Loop In C Language  A loop statement allows us to execute a statement or group of statements multiple times. Given below is the general form of a loop statement in most of the programming languages − C programming language provides the following types of loops to handle looping requirements. Sr.No. Loop Type & Description 1 while loop Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body. 2 for loop Executes a sequence of statements multiple times and abbreviates the code that manages the loop variable. 3 do...while loop It is more like a while statement, except that it tests the condition at the end of the loop body. 4 nested loops You can use one or more loops inside any other while, for, or do..while loop. While Loop in C A while loop is the most straightforward looping structure. While loop syntax in C programming language is as follows: Syntax of While Loop in C: while (condition) { statem

Basic Example Of C

C Program to check whether the given integer is positive or negative  /* Description : A program to check whether the input * integer number is positive or negative. * Written by : Santosh Asole */ #include <stdio.h> void main () { int num ; printf ( "Enter a number: \n" ); scanf ( "%d" , & num ); if ( num > 0 ) printf ( "%d is a positive number \n" , num ); else if ( num < 0 ) printf ( "%d is a negative number \n" , num ); else printf ( "0 is neither positive nor negative" ); } Output 1: Enter a number : 0 0 is neither positive nor negative Output 2: Enter a number : - 3 - 3 is a negative number Output 3: Enter a number : 100 100 is a positive number Program to find largest of three input numbers #include <stdio.h> int main () { int num1 , num2 , num3 ; //Ask user to input any three integer numbers p

Data Types in C

 Data Type in C Programming Type of data is know as Data type. int,float,char are example of data type in c There are two types 1. Primary data type 2. Derived data type. Primary data types Integer(int),floating(float),character(char),void are the primary data type Derived data types  arrays, functions, structures and pointers are Derived data types. Integer type Integers are used to store whole numbers. Floating type Floating types are used to store real numbers. Character type Character types are used to store characters value. void type void type means no value. This is usually used to specify the type of functions.

History of C

     History of C C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories to develop the UNIX operating system. C is the most widely used computer language. It keeps fluctuating at number one scale of popularity along with Java programming language, which is also equally popular and most widely used among modern software programmers. C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC PDP-11 computer in 1972. In 1978, Brian Kernighan and Dennis Ritchie produced the first publicly available description of C, now known as the K&R standard. The UNIX operating system, the C compiler, and essentially all UNIX application programs have been written in C. C has now become a widely used professional language for various reasons −   • Easy to learn

IMPORTANCE OF C

IMPORTANCE OF C The increasing popularity of C is probably due to its many desirable qualities. It is a robust language whose rich set of built-in functions and operators can be used to write any complex program. The C compiler combines the capabilities of an assembly language with the features of a high-level language and therefore it is well suited for writing both system software and business packages. In fact, many of the C compilers available in the market are written in C.     Programs written in C are eficient and fast. This is due to its variety of data types and powerful operators. It is many times faster than BASIC. For example, a program to increment a variable from O to 15000 takes about one second in C while it takes more than 50 seconds in an interpreter BASIC.     There are only 32 keywords in ANSI C and its strength lies in its built-in functions. Several standard functions are available which can be used for developing program    C is highly portable. This mea