Posts

Showing posts from January, 2020

See a problem in else if statement

Dangling else problem

Image
Hello, This problem comes when we use else if statement and do some mistake more describe is given below......... Dangling else problem: One of the major problem with nested if is dangling else problem. The problem arises when both outer if statement inner if statement might pair with common else statement. Thus the compiler is not able to judge to pair the else with which statement. The solution to this problem is given by the compiler that it pairs else with the recent if thus sometimes giving wrong result.                                           Hence the programmer should put early bracket wherever required. This post is may very short because my only aim was to describe this problem. Thank you, Keep supporting............. 

Storage Class in C Part 1

Hello guys today in this post we will discus about storage class. Storage class: Every identifiers not only has data type but also has a storage class the storage class the storage class of an identifiers determine the following character-  scope of an identifiers Storage of an identifiers Storage location of an identifiers  Lifetime of an identifiers Linkage of an identifiers Initial value of an identifiers The storage class of an identifiers can be specified will the help of storage class specified  following are storage class specifiers- auto static typedef register extern It most one storage  class specifier can be specified in a declaration statement. Auto: Keyword used in auto. By default an identifiers declared with in a block has auto storage class. The auto identifiers is stored in main memory. The lifetime of automatic storage class is local i.e. the identifiers will come into existence from the point if its declaration and remaining into e

Recursion

Image
Today we are going to discus about recursion topic in function.Simple words me ager aapko bata du iska use kerek hum kaafi bade programm ko short ker dete hai inka mean recursion ke progrma ki length normal function ke progream se kam hoti hai. Isme only thora sa thinking process hota hai . jisse hum ek statement aisa creat kerte hai jo ba rbar khub ko call kerta hai aur end me aapko result de deta hai. Recursion: Recursion is a powerful programming technique that can be used to solve the problem of smaller size.A function can call itself and the function is called as an recursion function. Recursion is classified according to following criteria - Whether function itself directly or indirectly. Whether there are any pending operation form the recursion call. Patter of recursion call. There are two type of recursion- Direct recursion Indirect recursion Direct recursion: A function is directly recursive if it call itself directly. That is a function body c

Rule of function declaration and type of variable

Image
Hello guys , today in this my post i will tell you some basic rule of  function declaration and how many types of variable we use in function . Rule of function variable: Find declaration needs to be ended using semicolon. Return type is optional. Type of  parameter & number of parameter are combings called parameter list. The parameter C in the list may or may not have parameter name. No parameter can have some names even parameter name and function name cannot be same. A function need not be declared if it is defined before it is called. Ex. Void add ( int , int ) The above declaration declare a function name and with two parameter of type of int and return type of void ( function does not return ).  Function header is same as function declare but without a semicolon,It consist of return type , function name , parameter type and no. of parameter. Variable: There are two types of variable in function- Local variable Global variable Local variabl

What is initialization ?

Image
Hello friends, I was forget to tell you about initialization so we will cover initialization here. Initialization: Variable are created for use in the program hence we need a value to the variable before using the variable.There are two type initialization- Compile time Run time Compile time: The initial value of the variable is known before execution of the program before the execution of the program. Dynamic (run ) initialization: If refers to run time initialization    initial value of the variable is not known until the program is executed. Comments: Comments are special feature of programming it is used to provide discussion to the programmer all user. These comments are only available therefore only available the logic as well as meaning of the variable used. Single line comment : It is use to give description that continuous in a single line the symbol use  //  Multiple line comment : Multiple line comment meant for describing statemen

Main function ,else if lader and nesting of loop

Image
                                C programming main function: Main function is a specially recognized function in C programming.Every program must have a main function to indicate where the program has to began its execution. While it is possible to code any program utilizing only main function. It leads a numbers of problem. This leads a number of problem. This leads to increase in completing and as  a result the task of debugging testing and maintaining  becomes difficult. If a program is divided into functional posts than each past may be independently managed. Else if lader- if(expression) { statement 1; . statement n; } else if (expression ) { statement 1; . statement n; } else if { statement 1; statement n; } else { statement 1; statement n; } If the expression 1 evaluate to be true , the if block is executed otherwise expression 2 is checked and if it evaluated to be true that particular else if block is executed and

Function Part 2

                              C programming  Type of function: No return type no argument - void small ( ) return type & no argument  - int small ( ) No return type & argument - void small ( ) Return type & argument - int small ( int , int) Advantages of function: There are several advantages of function - Reduction in code redundancy Enabling code reuse Better readability Information hiding Improved debugging & testing Improved maintainability  Clarification of function: Function can be classified as - user defined function  Library function 1. Library function: There are those functions whose functionality has already been developed by someone and are available to the user for use these are called library functions or pre defined function. Ex. printf(), scanf(), sqrt(), pow() etc. 2. User defined function: These are functions that are defined by the user at the time of writing a program the user. Develop the functional

Function Part 1

Hello, today we will learn about function in c programming............... Function: Function is self content block of code that performs a particular task. Most of the computer programs that solves much bigger and complex. Every C program can be thought as a collection of these functions. They interact with each other to accomplish a particular task function follows following approach. This approach of problem solving is called as conquer and divide strategy. Types of function: Function prototype /declaration Function  definition Function call    Function prototype: Syntax:    return type  function name  (parameter list) Ex. int sum (int a, int b) float mul (int, float, int) Function prototype consist of three part- return type type of parameter no. of parameter Function call: Function call by simply using function name following by a list of parameter. Syntax: function name (parameter list) Function definition : Function prototype con

Looping part 3(examples)

Image
In this post we define every loop by example and show you difference between them- Important point of for loop- There are three fields in the for loop which can be left vacant but initialization of counter variable should be done before the loops start executing as well as the counter is done with in the loop. If no condition is given with in the for statement by default it evaluates to be true. Infinite loop: Infinite loop means the body of the loop will executed infinitely without manual interaction this happens because the given test expression never evaluate to be false. Difference between do while and while loop use:  for loop example: wap to find out sum of even no. between 1 to n. #include<stdio.h> main() { int i=1,n,sum=0; printf("Enter the range:"); scanf("%d",&n); for(i=1;i<=n;i++) { if(i%2==2) sum=sum+i; } printf("Sum=%d",sum); } while loop example: Wap to find out sum of firs

Looping part 2

This is second part of looping here we continue our looping topic- Do-while: Do while loop is an exit control loop in which condition is tested on the exit of loop. The do while loop execute at least ones even if the condition is false. syntax: do { body_loop; } while( test expression); For loop: It is an entry control loop in this initializing of counter variable test expression, modification of counter variable is done at one syntax: for(initialization ; test expression ; modification of counter) { body_loop; } while executing the for loop. Initialized is done only once with the start of the execution of for loop.                               The test expression is checked if the expression evaluated to be true the body of the loop is executed the loop counter modified accordingly. the above two steps keeps or repeating till the test expression evaluated to be true. Thank  you, related to any this or another post question please comment

Looping part 1

Hello guys, today we are going to start looping.......... Looping: Looping means that a sequence of statement are executive until some conditions found false. A program loop therefore consist of two parts- Control statement Body of loop                      The control statement test certain conditions and then directs the replaced execution of the statement contain in the body of the loop.Looping structures are classified depending upon following categories - Depending upon position of control statement or test expression. Depending upon control variable portion. Depending upon looping process. Counter Control loop:            We use special variable called counter.In this type of loop the no. of  times the loop will execute is known in advance. There are three loops in C programming- while loop for loop do-while loop 1. While loop: Simplest form of looping is while loop. It is the entry control loop because the test expression is checked while en

Jump statement

Welcome friends in my new post here we going to study about jump statement........... Jump statement: A jump statement transfers control from one place to another without checking any condition.There are four types of jumps statements- break continue goto return Break: The break statement takes control out of the current block. syntax- break;                           A break statement can appear only with a switch case body or any looping statement body.If it is placed anywhere else in the program.We get the compiler time error. break statement terminate enclosing switch or nearest enclosing. Loop the execution resumes with statement presents with next to the terminated loop or switch statement. Continue: continue statement are used when we require skipped a part of block or statement and again start executing from the beginning of the block. syntax: continue; Continue statement appears only inside body of loop. goto lable: The goto statem

Dangling else problem

Image
Hello, This problem comes when we use else if statement and do some mistake more describe is given below......... Dangling else problem: One of the major problem with nested if is dangling else problem. The problem arises when both outer if statement inner if statement might pair with common else statement. Thus the compiler is not able to judge to pair the else with which statement. The solution to this problem is given by the compiler that it pairs else with the recent if thus sometimes giving wrong result.                                           Hence the programmer should put early bracket wherever required. This post is may very short because my only aim was to describe this problem. Thank you, Keep supporting............. 

Preprocessor directives short details

In this post we will discus about what is preprocessor directives ? Only some basic knowledge i am going to share with you and whole summary or chapter on this i will post letter.          Preprocessor directive: Preprocessor is a special functionality in language that process the source code before it passes to the compiler. It operates under a control of what is known as preprocessor directive. some types of directives are given below- Macro substitution  File inclusion  Line directive Compiler control directive Pregma control Directive 1. Macro substitution directive: It is a process where identifier is replace by predefined string composed of one or more tokens a preprocessor accomplishes this task under the direction of  #define token. There are two types of macros- Simple macro substitution Augmented macro substitution (a) Simple macro substitution : syntax: #define macro name  macro description  It is also called as object like macro. Ex.

Reading and writing floating number

Hello guys, now here we will continue on reading and writing floate number in my last post we learn about integer number reading and writing. Reading floating point no.: Reading a floating point number we use scanf with format specifiers %f. Writing floating point no.: we use %wpf where w indicates the no. of position that a used to display a value and integer p indicates the no. of digit to be displayed after the decimal points. And printed right justified in the field off w colums leaded blanks and trailing ). The negative no.'s will be displayed with the (-) sign. Ex.- if value of a =56.7432 printf("%7.4f",a); output-56.7462 print("%7.2f",a); output-56.75 printf("%-7.2f",a); output- _ _56.75 printf("%07.2f",a); ouput- 0056.75 Normally you have to only remember that if you write any float no. as we show in example that 's first no. will indicate how many no. will display and after d

Reading and writing integer number

Now here we describe how to read and write the integer number- Writing integer number: printf function is used for format specifier with wd where  w stands for bit and it is optional. Ex.  int a=51769; printf("%d",a); output=51769 printf("%8d",a); output=_ _ _51769 here when write 8d mean 8 box or part space create and number start filling from last. printf("%2d",a); output=51769 Reason: when w is lesser than data then no effect on output. printf(%08",a); output: 00051769 printf("%-8d %d",a,a); Output:51769_ _ _51769 Reading the integer number: To use integer number we use scanf, scanf("format_specifier",arg1,argg2,_ _ _ ); . The first specifiers is used to read integer no. is %wd where is w is the bit Ex. : a=51769 , b=25769 scanf("%2d %2d",&a,&b); output: In this value of  a will be starting two no. mean a=51 and value of b will not

use of getchar and putchar

Hello guys today i will tell you in this post , use of putchar and getchar............                          C programming Input and output functions: Generally we use printf and scanf as input output functions respectively  but there are various functions available for input and output. Input and output for character: Reading a character: In general scanf function is can be used to input a character but instead of that we can use getchar function. syntax: variable name=getchar();                  There are some functions that are used to test a character based on some requirement - isdigit (ch): It returns a non zero when character digit is digit otherwise returns a 0 value.                                                      isalpha: It returns a non 0 value if  character is alphabet otherwise returns 0 value.                                                      islower(ch): It returns a non 0 when character is in lower case alphabet otherwise returns 0 va

Types of conversion

                           C programming Types of conversion: implicit conversion explicit conversion Implicit conversion: Implicit conversion is done by the compiler according to some predefined rules this is also called as automatic conversion.It implicit conversion aperants of lower type are automatically converted to higher types. for ex: int is automatically converted to float.  A predefined heirarchy is used. Explicit conversion: Is done when higher type converted into lower type this kind of conversion can not perform by the compiler hence done explicitly. syntax- (type)value Ex-#include<stdio.h> main() { double a=5.2,b=2.3; int c; c=(int)(a/b); printf("%d",c); } List, here if you go down you have to use explicit conversion and if you come up in list you have to use implicit conversion. long double double float unsigned long int long int unsigned int int  short int, char here i discribe about implicit and expl

Decision control statement and looping statements part 2

                            C programming This is the second part of decision control statement here we will discus remaining two part of statement. if-else-if: if-else-if statement is used to test additional conditions. This is also known as nesting if statement.her e if else if  continuesly comes ,first if else statement write than next if else will be start from first else in simple words if else statement when used inside any if else block. Switch statement: A witch statement is a multi-way decision statement that is a simplified version of an if -else-if block that evaluate only one variable.the general form of  switch statement shown in figure- syntax: switch (var) { case 1: { Statement 1; break; } case 2: { Statement 2; break;  } case 3: { Statement 3; break;; } Statement n; } Thank you, keep supporting, If any doubt please comment below....................

Decision control and Looping statement part 1

                       C programming Decision control and looping statements: Introduction: The  decision control statements  are the  decision  making  statements  that decides the order of execution of  statements  based on the conditions. In the  decision  making  statements  the programmer specify which conditions are to be executed or tested with the statement  to be executed if the condition is true or false. Conditional Branching statement: The conditional branching statement help to jump from one part of the program to another depending on whether a particular condition is satisfied or not.These decision control statement statement include - if statement  if else statement if else if statement switch statement  if statement: The if statement is the simplest form of the simplest from of the decision control statement. This is frequently used in decision making. syntax: if ( test expression ) { statement 1; -------------- ----------

Introduction to C part-3

                                   C programming Operator: An operator is a symbol that specifies the mathematical, logical or realation operation to be performed. C language supports different type off operators which is used with the variables. Operators in C: Arithmetic  Relational Equality Logical  Unary Conditional   Bitwise Assignment  Comma Size of operator Arithmetic operator: Arithmetic operators  take numerical values (either literals or variables) as their operands and return a single numerical value. The standard  arithmetic operators  are addition (+), subtraction (-), multiplication (*), and division (/). Relational operator: Relational operator is also known as comparison operator. This operator compares two values. Relational operator returns a true or false value. Ex.- < , >, <= , >= . Equality Operator: C language supports two kind of equality operators. equal ( = ) not equal (! = ) Comparison Operators:  Greate

Introduction to C part 2

                                   C programming hello friends,this is second part of introduction of C. Identifiers: Identifiers help us to identify data and other objects in the program. Identifiers are basically the name given to program elements such as variables,array and functions. Identifiers cannot include any special characters or punctuation marks except the underscore. Keywords cannot be used as identifiers. Identifiers must began with a letter or an underscores. Basic Data Types in C: C language provide very few basic data types. Variables: A variable is defined as a meaningful name given to a data storage location in computer memory.C language supports two basic kinds of Variables- numeric and character. Constants: Constants are identifiers whose value do not change.While value of variables can be changed at any time. Input/output statement in C: printf: The printf function is used to display information required by the user and also d

Introduction to C part 1

                             C programming      Structure of the program There are 6 section in C program - 1. Documentation section  2. Link  3. Definition section 4. Global declaration 5. Main section 6. Subprograms ex.  #include<stdio.h> main() { printf("Hello C world"); } #include<stdio.h> : This is a pre processor command that comes as the first statement in our code. #include statement tells the compiler to include the standard input/output library or header file in the program. main() : Every C program contains a main function which is the starting point of the program. Files used in C program: Source code Files: The source code file contains the source code of the program .This file contains C source code that defines the main function and maybe other functions. Header Files: when working with large project it is often desirable to separate out certain subroutines from the main function of the progra

Introduction of C language

                           Tutorial of C language Hello, my name is Aneesh Mishra this is first blog.I am going to create blog on c language as you read in description i will post here every language full tutorial or course free for students ,who want to make future in programming. (If you want c language tutorial in hindi please comment below.) Introduction: In starting i choose C language for create blog  because c language is also known as mother language of programming language if you learn all concept of c clearly you can sure learn any language.                            Before learn any language we should know that language history and every quite knowledge of that .                            The programming language C was  developed in the early 1970s by Dennis Ritchie at Bell Laboratories to be used by the UNIX  operating system .It was named 'C' because many of its features were derived from an earlier language 'B'.Although C was de