Posts

C ASCII Code

Image
#include <stdio.h> int main() { char chr; printf("Enter a character: "); scanf("%c",&chr);     // When %c text format is used, character is displayed in case of character types printf("You entered %c.\n",chr);  // When %d text format is used, integer is displayed in case of character types printf("ASCII value of %c is %d.", chr, chr);  return 0; } By adding // we can denote a comment in C. In the above example i have described the code inside of it by using comments. The output of the above code

C - Input/Output

Image
#include <stdio.h> int main() {     int testInteger;     printf("Enter an integer: ");     scanf("%d",&testInteger);      printf("Number = %d",testInteger);     return 0; } Above program shows how we can input value to a program and how to print that value entered. %d is used to indicate integer input or output. Same as that we use, %f - float %c or %s - char %f - double

C- Escape Sequences

Sometimes, it is necessary to use characters which cannot be typed or has special meaning in C programming. For example: newline(enter), tab, question mark etc. In order to use these characters, escape sequence is used. For example: \n is used for newline. The backslash ( \ ) causes "escape" from the normal way the characters are interpreted by the compiler. Escape Sequences Character \b Backspace \f Form feed \n Newline \r Return \t Horizontal tab \v Vertical tab \\ Backslash \' Single quotation mark \" Double quotation mark \? Question mark \0 Null character

C-Data Types and Variable Naming

Data Types C supports several different types of data, each of which may be represented differently within the  memory. Some of the data types used in C language are,    int    char    short    double     float Variable Naming Only underscores, letters and digits are allowed in variables.  No special characters allowed other than underscore. First character should be a letter or a underscore. you can't have reserved words as the variable name.            ex: int , char , continue But you can have reserved words as variable name by capitalizing one or more letters in the word.            ex: iNt, conTinue Variable names are case sensitive. And there are constants A constant is a value or an identifier whose value cannot be altered in a program.            ex: 1, 2.5, "C programming is...

Programming With C Language

Image
First Program In C C  is a high-level and general-purpose  programming language  that is ideal for developing firmware or portable applications. Originally intended for writing system software,  C  was developed at Bell Labs by Dennis Ritchie for the Unix Operating System in the early 1970s. C language is a case sensitive language. To do programming in C first we should install a C editor such as Turbo C,C free,codeblocks etc. In here i am using codeblocks as my editor. But also we can do coding in notepad also.  After installation now we are going to write our first program. open codeblocks get a new empty file and write the code below. #include<stdio.h>← header file int main()← function   ↑ return type {     printf("Hello World \n");     return 0;                     ↑ }                    ...