Posts

Introduction to C Programming | C Programming

Image
Introduction to C Programming ±    C is a general-purpose high level language ±    Father of C – Dennis Ritchie ±    Originally developed for the UNIX operating system ±    Implemented on the Digital Equipment Corporation, PDP-11 computer in 1972 ±    The UNIX operating system and all UNIX applications are written in the C language   C has now become a widely used professional language for various reasons: ±     Easy to learn ±     Structured language ±     It produces efficient programs ±     It can handle low-level activities ±     It can be compiled on a variety of computers Why we use C? ±    C was initially used for system development work, in particular the programs that make-up the operating system ±    C was adopted as a system development language because it produces code that runs nearly as fast as code written in assembly language. ±    Some examples of the use of C might be: °     Operating Systems °     Language Compilers

C Program to Find Area and Perimeter Using function | C Programming

Image
C Program to find the Area and Perimeter of a Rectangle using function Source Code (Finding Area) #include <stdio.h> int area ( int , int ); int main () {     int len , bred , a ;     printf ( "Enter length of rectangle:-\n" );     scanf ( " %d " , & len );     printf ( "Enter breadth of rectangle:-\n" );     scanf ( " %d " , & bred );     a = area ( len , bred );     printf ( "The area is %d " , a );     return 0 ; } int area ( int a , int b ) {     int area ;     area = a * b ;     return area ; } Source Code (Finding Perimeter) #include <stdio.h> int perimeter ( int , int ); int main () {     int len , bred , p ;     printf ( "Enter length of rectangle:- \n " );     scanf ( " %d " , & len );     printf ( "Enter breadth of rectangle:- \n " );     scanf ( " %d " , & bred );     p = perimeter ( len , bred );     printf ( "The perimeter is %d .&quo

C Program to check whether the current year is a leap year or not | C Programming

Image
C Program to check whether the current year is a leap year or not #include <stdio.h> int main () {   int a ;   printf ( "Enter the current year:" );   scanf ( " %d " , & a );   if ( a % 4 == 0 && a % 100 == 0 && a % 400 == 0 )     printf ( "It is a leap year." );   else if ( a % 4 == 0 && a % 100 != 0 )     printf ( "It is a leap year." );   else     printf ( "It is not a leap year." );   return 0 ; } Output

Escape Sequence in C Programming | C Programming

Image
Escape Sequences in C Programming:- An escape sequence always begins with backward slash and is followed by one or more special characters.  For example:- a line feed (LF), which is referred to as new line in C can be represented as \n. Backslash character constants are special characters used in output functions. Although they contain two characters they represent only one character.

Identifiers and Keywords in C Programming | C Programming Language

Identifiers in C Identifiers refers to the name given to the entities such as variables, functions, structures etc. Identifiers must be unique. They are created to give unique name to the entity to identify it during the execution of the program. For example:- int money; double account balance; Here, money and account balance are identifiers. Rules of writing identifiers First character must be an alphabet (or underscore) Identifier names must consists of only letters, digits and underscore. An identifier name should have less than 31 characters.  Any standard C language keyword cannot be used as a variable name. An identifier should not contain a space.  Keywords in C-: Key words are predefined, reserved words used in programming that have special meanings to the compiler. Keywords are the part of the syntax and they cannot be used as an identifier.  For example:-  int money; Here, int is the keyword that indicates money is a variable of the type in

C Program To Find The Odd Numbers

Image
C Program To Find The Odd Numbers Within The Certain Declared Values #include <stdio.h> int main () {   int i , n ;   printf ( "Enter the max number: " );   scanf ( " %d " , & n );   printf ( "The odd number upto %d are: \n " , n );   for ( i = 0 ; i < n ; i += 2 )     printf ( " %d \n " , i + 1 );   i ++;   return 0 ; } Output

C Program To Find Factorial | C Programming

Image
C Program To Find Factorial #include <stdio.h> int main() {      int n, i,factorial = 1;      printf("Enter an integer: ");      scanf("%d",&n);      if (n < 0)          printf("Error! Factorial of a negative number doesn't exist.");      else      {          for(i=1; i<=n; ++i)          {              factorial *= i;          }          printf("Factorial of %d = %d", n, factorial);      }      return 0; } OUTPUT