Posts

Showing posts from January 28, 2018

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

C Program To Print Multiplication Table Of Any Numbers Up To Any Terms | C Programming

Image
C Program To Print Multiplication Table Of Any Numbers Up To Any Terms  #include<stdio.h> int main() {int n1,n2,i; printf("Enter the number:"); scanf("%d",&n1); printf("Enter the term up to which you want to multiply:"); scanf("%d",&n2); for(i=1;i<=n2;i++) {printf("%d X %d = %d\n",n1,i,n1*i); } return 0; } OUTPUT

C Program to print opposite number right angled triangle pattern | C programming

Image
A  for  loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times. Syntax The syntax of a for loop in C programming language is − for ( init; condition; increment ) {    statement(s); } Here is the flow of control in a 'for' loop − ·       The  init  step is executed first, and only once. This step allows you to declare and initialize any loop control variables. You are not required to put a statement here, as long as a semicolon appears. ·       Next, the  condition  is evaluated. If it is true, the body of the loop is executed. If it is false, the body of the loop does not execute and the flow of control jumps to the next statement just after the 'for' loop. ·       After the body of the 'for' loop executes, the flow of control jumps back up to the  increment  statement. This statement allows you to update any loop control variables. This statement can be left blank, as long as a

C Program to check the length of string | C Programming

Image
String The way a group of integers can be stored in an integer array. Similarly, a group of characters can be stored in a character array. Character arrays are many a time also called strings. Many languages internally treat strings as character arrays, but somehow conceal this fact from the programmer. Character arrays or strings are used by programming languages to manipulate text such as words and sentences. A string constant is a one-dimensional array of characters terminated by a null ( ‘\0’ ).  For example, char name [ ] = { 'H' , 'A' , 'E' , 'S' , 'L' , 'E' , 'R' , ' \0 ' } ; C Program to count the length of the string #include <stdio.h> int main () {   char str [ 50 ];   int i , count = 0 ;   printf ( "Enter a line:- \n " );   scanf ( " %c " , & str );   for ( i = 0 ; str [ i ] != ' \0 ' ; i ++)   {     count ++;   }   printf ( "The length of the string is %d .

C Program To Print Chess Board | C Programming

Image
C Program To Print Chess Board #include <stdio.h> int main () {     int i,j,num;     printf ( "Enter the number : " );     scanf ( " %d " ,&num);     for (i= 0 ;i<num;i++)     {         for (j= 0 ;j<=num;j++)         {             printf ( " %c " , 219 ); //219 is the ASCII cose for white             printf ( " " );         }         printf ( " \n " );         if (i% 2 == 0 )         {             printf ( " %c " , 255 ); //255 is the ASCII cose for white         }     }     return 0 ; } OUTPUT