How to Run Command Prompt as an Administrator

In this topic you will learn how to open a command prompt with full administrator permissions. There are Four easy methods to run command prompt as administrator such as Start Menu, Folder file menu , Quick Access Toolbar and from context menu. This method works on windows 8 and 8.1. The context menu method is also works on windows 7.

1.Run from Start Menu.

  1. Click Start.
  2. In the Start Search box, type cmd
  3. Right-click Command prompt, and then click Run as administrator.
  4. In the User Account Control dialog click yes to Continue.
 &nbsp &nbsp &nbsp[>>>  OR  <<<]
  1. Click Start.
  2. In the Start Search box, type cmd, and then press "Ctrl+Shift+Enter".
  3. In the User Account Control dialog click yes to Continue.

2.Run from any Folder.

  1. Open Folder.
  2. Click File menu and then navigate to Open command prompt.
  3. In "Open command prompt" you find two way normal method and admin method.
  4. Click " Open command prompt as administrator" to open.

3.Run form Quick Access Toolbar.

  1. Open Folder.
  2. Click File menu and then navigate to Open command prompt.
  3. In "Open command prompt&auot; you find two way normal method and admin method.
  4. Right Click on "Open command prompt as administrator" after that click "Add to Quick Access Toolbar".
  5. Now you can open admin cmd easily form Quick access toolbar.

4.Run form Context Menu.

Install Registry key in your system to run command prompt as administrator from context menu.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\background\shell\runas]
"icon"="imageres.dll,73"
@="Run CMD as administrator"

[HKEY_CLASSES_ROOT\Directory\background\shell\runas\command]
@="cmd.exe /s /k \"pushd %V && title Command Prompt\""

Download Run CMD as administrator.zip

Video

Escape Sequences in C

Escape Sequences in C
Escape sequence are useful for formatting the Input and Output. All Escape sequences are start from Back slash " \" followed by a character.  The " \n " new line is most commonly used in printing statement.

Escape Sequence with ASCII Value


Character   Escape Sequences     ASCII Value  
Null \0 0
Bell (alert) \a 7
Backspase \b 8
Horizontal tab \t 9
New line \n 10
Vertical tab \v 11
Formfeed \f 12
  Carriage return   \r 13
Double quote \" 34
Single quote \' 39
Question mark \? 63
Backslash \\ 92
Octal number \ooo any
Hexadecimal
number
\xhh any

Octal Number:
Example: \7, \007, \786
Hexadecimal Number:
Example: \x5, \x57, \x7f

Program to display ASCII value
#include <stdio.h>
int main(){
printf("Null=%d\n",'\0');
printf("Bell (alert)=%d\n",'\a');
printf("Backspase=%d\n",'\b');
printf("Horizontal tab=%d\n",'\t');
printf("New line=%d\n",'\n');
printf("Vertical tab=%d\n",'\v');
printf("Formfeed=%d\n",'\f');
printf("Carriage return=%d\n",'\r');
printf("Double quote=%d\n",'\"');
printf("Single quote=%d\n",'\'');
printf("Question mark=%d\n",'\?');
printf("Backslash=%d\n",'\\');
return 0;
}

Output

Null=0
Bell (alert)=7
Backspase=8
Horizontal tab=9
New line=10
Vertical tab=11
Formfeed=12
Carriage return=13
Double quote=34
Single quote=39
Question mark=63
Backslash=92

Example program to print Escape sequences and percentage symbol.
#include <stdio.h>
int main(){
printf("\aC Program\n");
printf("New line =\\n\n");
printf("Percentage symbol=%%");
return 0;
}


Operator Precedence in c

Operator Precedence in c
When two or more operators share an operand the operator with the higher precedence goes first. For an example, 1 + 2 * 3 is treated as 1 + (2 * 3), because multiplication has a higher precedence than addition.

Operator Precedence and Associativity


Priority Category Operator What is it (or does) Associativity
1 Highest ( )
[ ]
->
.
Function call
Array subscript
Indirect component selector
Direct component selector
Left to Right
2 Unary !
~
+
-
++
--
&
*
sizeof
(type)
Logical negation (NOT)
Bitwise (1's) complement
Unary plus
Unary minus
Preincrement or postincrement
Predecrement or postdecrement
Address
Indirection
Size of operand, in bytes
TypeCast
Right to Left
3 Multiplicative *
/
%
Multiply
Divide
Remainder (modulus)
Left to Right
4 Aditive +
-
Binary plus
Binary minus
Left to Right
5 Shift <<
>>
Shift left
Shift right
Left to Right
6 Relational <
<=
>
>=
Less than
Less than or equal to
Greater than
Greater than or equal to
Left to Right
7 Equality ==
!=
Equal to
Not equal to
Left to Right
8 Bitwise AND & Bitwise AND Left to Right
9 Bitwise XOR ^ Bitwise XOR Left to Right
10 Bitwise OR | Bitwise OR Left to Right
11 Logical AND && Logical AND Left to Right
12 Logical OR || Logical OR Left to Right
13  Conditional ?: "a ? x : y" means "if a then x, else y" Right to Left
14 Assignment =
*=
/=
%=
+=
-=
&=
^=
|=
<<=
>>=
Simple assignment
Assign product
Assign quotient
Assign remainder (modulus)
Assign sum
Assign difference
Assign bitwise AND
Assign bitwise XOR
Assign bitwise OR
Assign left shift
Assign right shift
Right to Left
15 Comma , Evaluate Left to Right


Example for Operatro precedence
#include <stdio.h>
int main(){
float a=1,b=2,c=3,d;
d=a+b*c;
printf("a+b*c=%f\n",d);

d=(a+b)*c;
printf("(a+b)*c=%f",a);
return 0;
}

Output

a+b*c=7.000000
(a+b)*c=1.000000

Punctuator in C

Punctuator in C
A punctuator is also a token and it also defined in compiler like keywords. A punctuator can also be a token that is used in the syntax of the preprocessor. some Operator or punctuator alternative representations for some operators and punctuators.

Punctuator

Operator Meanning
[ ] Array subscript Operator
( ) Parentheses Operator
{ } Braces
= Equal sign
, Comma Operator
(or)
Punctuator
: Colon
; Semicolon
* Astrisk
" " Quotes
' ' Ellipsis


C and C++ ( C99 ) provide the following alternative representations for some operators and punctuators.
Operator
or
punctuator
Alternative
Representation
# %:
## %:%:
{ <%
} %>
[ <:
] :>

Example for using Alternative representation.
// Alternative Representation Example
%:include<stdio.h>
int main()
<%  //  Open Brace {.
char a<:5:>="MDSN";  // Array subscript operator Ex: a[5]="MDSN"
printf("%s",a);  // Output MDSN
return 0;
%>  // Close Brace {.

Some more alternative representation defined as macros in the header file " iso646.h".
Operator
or
punctuator
Alternative
Representation
& bitand
&& and
&= and_eq
| bitor
|| or
|= or_eq
^ xor
^= xor_eq
! not
!= not_eq
~ compl

Example:
  %:include<stdio.h> //  # preprocessor 
  %:include<iso646.h>
  int main()
  <%  //  Open Brace {.
  int a=5,b=5,c=2;
  if((a==5)and(a==b)) //if((a==5)&&(a==b))
  {printf("a=5 and a=b\n");}
  
  if(a not_eq c) //if(a != c)
  {printf("a is not equal to c\n");}
  return 0;
  %>  // Close Brace {.

Unary Operators in C

Unary Operators in C
Unary Operators are written before their single operand some Unary Operators written after their operands. Most commonly unary minus is used in the program.

Unary Operator

  Operator   Meaning
& Referencing Operator
* Dereferencing Operator
+ Unary PlusOperator
- Unary Minus Operator
++ Increment Operator
-- Decrement Operator
! Logical Not Operator
~   Bitwise Complement Operator  
sizeof Size of operand in bytes
(type) Type Cast

Referencing operator ('&')

Referencing operator ( & ) produces the address of a variable, Ex: &a is a pointer to a. the
parameters are declared as pointers, and the operands are accessed indirectly through them.

Dereferencing Operator ('*')

The unary operator "*" is Dereferencing Operator and it applied to a pointer, it
accesses the object the pointer variable. Ex: *a.

Unary ( +, - ) Operator

The operands of the unary "+" and "-"operator must have arithmetic type, and the result is the value of the operand. The type of the result is the type of the promoted operand.

Increment Operator (++) & Decrement Operator (--)

The "++" adds one to the variables and "--" subtracts one from the variable. Because it acts upon only one variable.
  Operator   Meaning
++a Pre increment
a++   Post increment  
--a Pre decrement
a-- Post decrement
  Consider the statement
a=5, b=5
  Expression     Value  
++a 6
a++ 6
--b 4
b-- 4
Coding for the above Example:
#include<stdio.h>
  int main()
  {
  int a=5,b=5;
  printf("Value of a=%d\n",a);
  printf("Pre increment %d\n",++a);
  printf("After pre increment the value of a=%d\n",a);
  printf("Post increment %d\n",a++);
  printf("After post increment the value of a=%d\n\n",a);
printf("Value of b=%d\n",b);
  printf("Pre decrement %d\n",--b);
  printf("After pre decrement the value of a=%d\n",b);
  printf("Post decrement %d\n",b--);
  printf("After post decrement the value of a=%d\n",b--);
return 0;
  }

Output

Value of a=5
Pre increment 6
After pre increment the value of a=6
Post increment 6
After post increment the value of a=7

Value of b=5
Pre decrement 4
After pre decrement the value of a=4
Post decrement 4
After post decrement the value of a=3

Logical Not Operator

The variable(operand) must be of scalar type (i.e. not an array, a structure or an union).
Consider the statement
a=5,b=7,c=5
  Expression     Interpretation     Value  
!(a==c) False 0
!(a==b) True 1

Bitwise Complement Operator

operand must be of integral type. Each 0 bit in the operand is set to 1, and each 1 bit in the operand is set to 0.
Consider the statement
X=19;
Z=~x;
X=0001 00112
Z=1110 11002

Sizeof Operator

The "sizeof" Operator returns the size of the variable or type. It returns the size in bytes.
#include<stdio.h>
int main()
{
int m;
printf("%d",sizeof(int));
printf("\n%d",sizeof(m));
return 0;
}

Type Cast

Type casting is a way of converting a variable form one data to another data type. For an example if you want to store a integer value into a float then you can type cast int to float.
#include<stdio.h>
int main()
{
int a=5,b=3;
float c;
c=(float) a/b;
printf("a/b=%f",c);
return 0;
}

Logical Operators in C

Logical Operators in C
Logical Operators are useful in combining one or more conditions. C allows usage of three logical operators namely " &&, ||, ! ".

Logical Operators

  Operator   Meaning
&&   Logical AND  
|| Logical OR
! Logical NOT

Truth Table of Logical Operator

In the following table
if True(T) means value is one.
If False(F) means valuse is Zero.
  X     Y     !X     !Y     X && Y     X || Y  
F F T T F F
F T T F F T
T F F T F T
T T F F T T
Consider the statement
a=5,b=7;c=5;
  Expression     Interpretation     Value  
(a>=5)&&(a<b) True 1
!(a==c) False 0
(a!=5)||(b>c) True 1
!(a==b) True 1

Codings for the above Example:
#include<stdio.h>
  int main()
  {
  int a=5,b=7,c=5;
  
  if((a>=5)&&(a<b)){printf("\"(a>=5)&&(a<b)\" = True\n");}
  else{printf("\"(a>=5)&&(a<b)\" = False\n");}
  
  if(!(a==c)){printf("\"!(a==b) or a is not equal to c\" = True\n");}
  else{printf("\"!(a==b) or a is not equal to c\" = False\n");}
  
  if((a!=5)||(b>c)){printf("\"(a!=5)||(b>c)\" = True\n");}
  else{printf("\"(a!=5)||(b>c)\" = False\n");}
  
  if(!(a==b)){printf("\"!(a==b) or a is not equal to b\" = True\n");}
  else{printf("\"!(a==b) or a is not equal to b\" = False\n");}
  
  return 0;
  }

Relational operator in C

Relational operator in C
The relational operators allows to compare two or more values to see whether they are equal or unequal.

Relational operator

  Operator   Meanning
< Is less than
<= Is less then or equal to
> Is greater then
>=   Is greater then or equal to  
!= Is not equal to
== Is equal to

Consider the statement
a=1,b=2,c=3;
  Expression     Interpretation     Value  
a<b True 1
b>c False 0
a<=b True 1
c>=b True 1
c!=3 False 0
a==1 True 1

Codings for the above Example:
#include<stdio.h>
  int main()
  {
  int a=1,b=2,c=3;
if(a<b)
  {printf("a is less then b  ,value= 1 \n");}
  else{printf("a is not less then b  ,value=0 \n");}
if(b>c)
  {printf("b is greater then c  ,value=1 \n");}
  else{printf("b is not greater then c  ,value=0 \n");}
if(a<=b)
  {printf("a is less then or equal to b  ,value=1 \n");}
  else{printf("a is not less then or equal to b  ,value=0 \n");}
if(c>b)
  {printf("c is greater then or equal to b  ,value=1 \n");}
  else{printf("c is not greater then or equal to b  ,value=0 \n");}
if(c!=3)
  {printf("c is not equal to 3  ,value=1 \n");}
  else{printf("c is equal to 3  ,value=0 \n");}
if(a==1)
  {printf("a is equal to 1  ,value=1 \n");}
  else{printf("a is not equal to 1  ,value=0 \n");}
  return 0;
  }

Output

a is less then b ,value= 1
b is not greater then c ,value=0
a is less then or equal to b ,value=1
c is greater then or equal to b ,value=1
c is equal to 3 ,value=0
a is equal to 1 ,value=1

Conditional Operator in C

Conditional Operator in C
Conditional Operator is also known as Turnary Operator. It is an alternate method to using a simple if-else. It checks the condition and executes the statement depending on the condition.

Syntex

condition?expression1:expression2;

if condition is True or value 1 means expression1 will execute.
if condition is False or value 0 means expression2 will execute.
Example:
Consider the statement
a=7,b=5
c=(a>b) ? a:b;
after execution the value of c=7
Example 1:
#include<stdio.h>
int main()
{
int a=7,b=5,c;
c=(0) ? a:b;   // c=5
printf("c=%d\n",c);
c=(1) ? a:b;   // c=7
printf("c=%d\n",c);
return 0;
}

Example 2:
#include<stdio.h>
int main()
{
int a=7,b=5,c;
c=(a>b) ? a:b;
printf("c=%d",c);
return 0;
}

Example :3
// Conditional operator using multiple function
  #include<stdio.h>
  int comp();
  int prin1();
  int prin2();
  int main()
  {
  comp()?prin1():prin2();//multiple function using Turnary Operator
return 0;
  }
 /* Comparing the values in comp()[function]
  int comp()
  {
  int a=7,b=5;
  if(a<b)
  {return 0;}
  if(a>b)
  {return 1;}
  }
 
int prin1() // printing function 1
  {
  printf("A is bigger\n");
  return 0;
  }
  
int prin2() // printing function 2
  {
  printf("B is bigger\n");
  return 0;
  }

Bitwise operator in C

Bitwise operator in C
Bitwise operator permit the programmer to access and manipulate individual bits within a piece of data. These operators can operate upon ints and chars but not on floats and doubles.

Bitwise operators

  Operator   Meaning
& Bitwise AND
| Bitwise OR
^
Bitwise XOR
<< Shift Left
>> Shift Right
~   Bitwise Complement 
(or)
One's Complement

Bitwise Operatot Truth Table

Bitwise Operator performs bit by bit operation.
  X     Y     X & Y     X | Y     X ^ Y  
0 0 0 0 0
0 1 0 1 1
1 0 0 1 1
1 1 1 1 0

Left Shift Operator

Consider the statement
X=19;
Z=X<<2;
The value in the integer X is shifted left by two bit positions. The result is assigned to Z.The value of X is 0001 00112 the value of Z after the execution the value of Z is 0100 11002.

  0001 00112   Left Shift(2) 
0100 11002  <-- Insert 2 Zero's (0) 

Right Shift Operator

Consider the statement
X=19;
Z=X<<2;
The value in the integer X is shifted Right by two bit positions. The result is assigned to Z.The value of X is 0001 00112 the value of Z after the execution the value of Z is 0000 01002.

 Right Shift(2)   0001 00112 
  Insert 2 Zero's (0) -->  0100 11002

Bitwise Complement Operator

operand must be of integral type. Each 0 bit in the operand is set to 1, and each 1 bit in the operand is set to 0.
Consider the statement
X=19;
Z=~x;
X=0001 00112
Z=1110 11002

Bitwise operator Example:
#include<stdio.h>
int main()
{
int X=19,Y=16,Z;
Z=X&Y;
printf("X&Y=%d\n",Z);
Z=X|Y;
printf("X|Y=%d\n",Z);
Z=X^Y;
printf("X^Y=%d\n",Z);
Z=X<<2;
printf("X<<2=%d\n",Z);
Z=X>>2;
printf("X>>2=%d\n",Z);
Z=~X;
printf("~X=%d\n",Z);
return 0;
}

Output

X&Y=16
X|Y=19
X^Y=3
X<<2=76
X>>2=4
~X=-20

Assume that X=19, Y=16, the binary format will be as follows.
X = 0001 00112 - 1910
Y = 0001 00002 - 1610
Binary  Decimal 
 X & Y   0001 0000  1610
X | Y 0001 00112 1910
X ^ Y 0000 00112 310
X<<2 0100 11002 7610
X>>2 0000 01002 410
~X 1110 11002 -2010

Assignment Operators in C

Assignment Operators in C
Assignment Operators are used to assign a value of an expression or a value of a variable to another variable. The most commonly used assignment operator is "=". There are two different Assignment Operators are available in C 1.Compound Assignment, 2.Multiple Assignment.

Syntex

variable = expression (or) value;
The '=' operator is the simple Assignment operator. Example:
#include<stdio.h>
int main()
{
int x; // Declaration of a variable
x=5;   // Assignment Operator
printf("x=%d",x);
return 0;
}

Compound Assignment

Compound Assignment Operator is to assign a value to a variable in order to assign a new value to a variable arter performing a specifed operation.
  Operator     Example     Meaning  
+ = X + = Y X = X + Y
- = X - = Y X = X - Y
* = X * = Y X = X * Y
/ = X / = Y X = X / Y
% = X % = Y X = X % Y
#include<stdio.h>
int main()
{
int x=5,y=5; // Declaration of a variable
x+=y;   // Compound Assignment X = X + Y
printf("x=%d",x);
return 0;
}

Multiple Assignment

Using Multiple Assignment we can assign a single value or an expression to multiple variables. Example:
#include<stdio.h>
int main()
{
int x,y,z=5; // Declaration of a variable
x=y=z;   // Multiple Assignment X=Y=Z(5)
printf("x=%d,y=%d,z=%d",x,y,z);
return 0;
}

Arithmetic Operators in C

Arithmetic Operators in C
In "C " language we can carryout basic arithmetic operation like addition, subtraction, multiplication and division. Both unary and binary are Arithmetic Operator.

Arithmetic Operators

  Operator   Meaning   Example  
+ Addition 7 + 3 = 10
- Subtraction 10 - 3 = 7
*   Multiplication   5 * 2 = 10
/ Division 10 / 2 = 5
% Modulus 9 % 2 = 1
//  Arithmetic Operators
#include<stdio.h>
int main()
{
int X=16,Y=10,Z;
Z=X+Y;
printf("X+Y=%d\n",Z);
Z=X-Y;
printf("X-Y=%d\n",Z);
Z=X*Y;
printf("X*Y=%d\n",Z);
Z=X/Y;
printf("X/Y=%d\n",Z);
Z=X%Y;
printf("X%%Y=%d\n\b",Z); 
return 0;
}

Output

X+Y=26
X-Y=6
X*Y=160
X/Y=1
X%Y=6

Operator and Punctuators

Operator and Punctuators
An operator is a symbol that specifies an operation to be performed on the operands. The data items are called operands. The operators are usually form a part of mathematical or logical expressions.

Types of Operator and Punctuators

  • Arithmetic Operator
  • Assignment Operator
  • Bitwise Operator
  • Conditional Operator ( Ternary Operator )
  • Logical Operator
  • Relational Operator
  • Unary Operator
  • Punctuators

Constants ( Literals )

Constants ( Literals )
The values cannot be changed during the execution of program are called constants. The fixed values are also called literals.

Types of Constants ( Literals )

  1. Integer Constants
  2. Float Constants
  3. Character Constants
  4. String Constants

Integer Constants

Integer Constants are numbers that do not have a decimal point or an exponential part.
They can be represented as:
Decimal Number 0 to 9 Ex: 7, 8, 6, -80, 786, etc.,
Octal Number 0 to 7 EX: 0, 012, 052, etc.,
Hexadecimal Number  0 to 9, A, B, C, D, E, F  Ex: 0x786, 0xA123, 0x2b, etc., 

Float Constants

Float Constants are numbers that have a decimal point or an exponential part.
They can be represented as:
 Float Constant  Value
7.867e3 7,867
4e-11 0.00000000004
1e+5 100000
7.e10 60000000000
0.16 0.16

Character Constants

Character Constants contains a single character enclosed within a single quotation mark symbol.
Ex: 'M', 'A', '9', '-', etc.., .

String Constants

A String Constants contains a sequence of characters or escape sequences enclosed in double quotation mark symbols.
EX:"MDSN", "Learn C\n", " ", etc.., .

How to Define a Constant in C

There are two simple ways to define Constants.
  1. #define ( Preprocessor)
    Example:
    
    #include <stdio.h>
    #define Length 10    //Preprocessor
    #define Width 5      //Preprocessor
    int main(){
    int Area;
    Area=Length*Width;
    printf("Area=%d",Area);
    return 0;
    } 
  2. const ( Keyword )
    Example:
    
     #include <stdio.h>
    int main(){
    const Length=10, Width=5;  // Keyword
    int Area;
    Area=Length*Width;
    printf("Area=%d",Area);
    return 0;
    } 

C and C++ Keywords

C and C++ Keywords
Keywords are already been explained in the C compiler. We can’t use keywords as variable names because it’s already defined in C compiler. The keywords are also called as “Reserved words”.

C and C++ Keywords

auto extern sizeof
break float static
case for struct
char goto switch
const if typdef
continue int union
default long unsigned
do register void
double return volatile
else short while
enum signed


C++ Kewords

asm inline this
bool mutable throw
catch namespace true
class new try
const_cast operator typeid
delete private typename
dynamic_cast protected using
explicit public virtual
export reinterpret_cast wchar_t
false static_cast
friend template

Identifier

Identifier
An identifier is a sequence of letters and digits. Identifiers are created to give unique name to C entities to identify it during the execution of program. It means names given to various program elements, such as variables, function, etc..,

Rules for naming an Identifier

  1. The first character must be “_”( underscore ) or any alphabet character.
    Ex: abc_, a_bc, a1bc, A1_bc
  2. We can use both upper and lower case but upper case character is not equal to lower case character.
    Ex: abc is not equal to ABC
  3. Keyword, special symbols and space are not allowed.
    EX: int, void, $abc, 1abc, a bc
  4. An identifier can be of any length while most of the C compiler recognizes only the first 31 characters.
The following program will helps you to understand more about Identifier.

// Identifiers are in this program : MD_SN, abc, ABC, a_bc1, A_BC2
#include <stdio.h>
  int MD_SN();
  char abc='M', ABC='D', a_bc1='S', A_BC2='N';
  int main()
  {
  MD_SN();
  return 0;
  }
  int MD_SN()
  {
  printf("%c%c%c%c",abc,ABC,a_bc1,A_BC2);
}

Output

MDSN

Tokens in C Programming language

Tokens in C Programming language
Dennis Ritchie and Brian Kernighan have included a reference manual to give explanation of the ANSI standard. The reference manual defines six classes of Tokens in C.

Tokens in C Programming language


A "C" program is constructed using tokens. Tokens are similar to building blocks of a program. The flowing form parts are not part of any six classes.
  • Blanks
  • Horizontal & vertical tabs,
  • Newlines
  • Formfeeds
  • Comments

C character set

C character set
A character denotes uppercase letters A to Z, lowercase letters a to z, digits 0 to 9 and special symbols.

Character set

  • The upper and lowercase letters of English alphabet:
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
    a b c d e f g h i j k l m n o p q r s t u v w x y z
  • Decimal Digits: 0,1,2,3,4,5,6,7,8,9
  • Special symbols:
    + - * / = ! @ # $ % ^ & ( ) { } [ ] . < > , : ; _ ? \ ' " white space(blank space)

Comment line in C Program

Comment line in C Program
The comment statement is not executable. Comments are like helping text in C program and they are ignored by the compiler and it is very helpful to understand the program easily. There are two types of comment in C program.
  1. Single line comment
  2. Multi line comment

1.Single line comment

  1. It can be Placed anywhere in C program
  2. Single line comment starts with " // "
  3. It can't be split over Multiple lines like Multi line comment
  4. Any symbols written after "//" will be ignored by C compiler.
Example:

// Title   :  Learn C
// Author  :  Mohamed Ushman
#include <stdio.h> 
int main()
 {
  printf("Learn C :)");   // Single line comment 
  return 0;// Until the end of line will be ignored by C compiler 
 }

2. Multi line comment

  1. It can be Placed anywhere in C program
  2. Single line comment starts with "/*" and ends with "*/"
  3. It can be split over Multiple lines
  4. It can be used like Single line comment
Example:

/*
  Title     :  Learn C
  Author  :  Mohamed Ushman
  */
  #include <stdio.h> 
  int main()
  {
  printf("Learn C :)");   /* It can be used like Single line comment */
/*-----------------------------------------------------------------
  printf("Learn C program");   Ignored By C Compiler
 ------------------------------------------------------------------*/
  return 0; 
  }

Different way of using comments

We can use comment to specify variables and some operation like addition, subtraction, etc.., .
Example:

/*********************************
  *    Title     :  Learn C
  *    Author  :  Mohamed Ushman
  *********************************/
  #include <stdio.h> 
  int main()
  {
  int a=5,b=5;
  int c;       //   To display output
  c=a+b;   //  Adition 
/*
  c=a-b;   //  Subtraction 
  */
printf("Value of c=%d",c);
  return 0; 
  }
  

Basic Structure of C Program

Basic Structure of C Program

Getting Started

Basic Structure of C Program

First step is to understand the structure of a “ C “ programming language using simple C program.
Let us look a simple code that would print the word “Learn C :) ”.

#include <stdio.h>
int main()
{
 /* My First program in C :) */
 printf("Learn C :)");
 return 0;
 }
 

Output

Learn C :)

S.no Coding Explanation
1 #include <stdio.h> This is a preprocessor command it tells the C compiler to include “stdio.h” from the C library before compiling a C program.
2 int main() This is the main function from where execution of any C program begins.
3 { This indicates the beginning of the main function.
4 /*_some_comments_*/
or
// some_comments
The comments are ignored by compiler. [ “ /*..*/ ”,” //... “ ]
5 printf("Learn C :)"); printf command prints the output onto the screen.
6 return 0; This command terminates C program (main function) and returns 0 value to the main function.
7 } This indicates the end of the main function.
 

Semicolon ( ; )

In C program, the semicolon is a statement terminator. In each individual statement must be ended with a semicolon.

Comma operator ( , )

The coma operator is used to separates the elements of variables in data type or element in array etc.
Ex: int a=7,b,c;

Whitespace (   )

Whitespace is the term used in C to describe blanks space like tabs, horizontal tab, newline characters(pressing Enter key and write coding in new line ) and space between comments. Whitespace separates one part of a statement from another and enables the compiler to identify elements in a statement.
Ex: int i, void main(), etc..,.

The following two example program will help you to learn more about whitespace.
Example: 1:-More Whitespace

#include <stdio.h>
  int main()
  {
  printf
  (
 " Learn C :) "
 )
  ;
  return 0;
  } 

Remember at least one whitespace character (space) between int main(), int i;, return 0;, etc..,
Example: 2:-

#include <stdio.h>
int main(){printf(" Learn C :) ");return 0;} 
The above two program output will be same

Output

Learn C :)

History of c programming language

History of c programming language
C programming language is a foundation of C++. Learning C is the first step to learn C++ because you cannot skip step, you must have to learn C before learning C++. C is one of the most widely used programming languages of all time. Many later languages like Objective-C, Java, JavaScript, C#, Perl, PHP, Python, etc.., have borrowed directly or indirectly from C language.

History of C Language

  • C is a programming language developed “ AT & T’s  Bell Laboratories ”  of USA  in 1972.  C was written by Dennis M.Ritchie.
  • Brian W. Kernighan and Dennis M. Ritchie produced the first publicly available description of  C known as “K&R C”.
  • The UNIX Operating System and essentially UNIX application program have been written in C.
  • The language was formalized in 1989 by American National Standards Institute (ANSI).
The following table illustrates the history of “ C “ Language.
Programming Language    Year    Founder
ALGOL 1960 International group
BCPL 1967 Martin Richards
B 1970 Ken Thompson
C 1972 Dennis Richie
K&R C 1978 Brian Kernighan and Dennis Ritchie
ANSI C 1989 ANSI Committee
ANSI/ISO 1990 ISO Committee

C89/C90 standard:

In 1990 ANSI C become ISO standard, the programming Language C is also called "C89" and "C90".

C99 standard:

C99 version published in 1999. It includes new futures like inline function and advanced data type and other changes.

C11 standard:

C11 standard adds new features to C and the library, including type generic macros, anonymous structures, improved Unicode support, atomic operations, multi-threading, and bounds-checked functions. It also makes some portions of the existing C99 library optional, and improves compatibility with C++.

Embedded C:

Embedded C includes features not available in normal C like fixed-point arithmetic, named address spaces, and basic I/O hardware addressing.

How to Copy a File Path to the Clipboard using Context menu

In this topic you will learn how to copy the full path of file or folder location to windows clipboard. It is very useful when we try to upload a file EX: Uploading file to email or uploading image to facebook etc..,

Copy File or Folder path Using context menu.

  1. Open Windows Explorer and navigate to the file or folder that you want to copy the path to clipboard.
  2. Hold the “Shift” Key and right click the file.
  3. In the context menu click “Copy as path” to copy the file path location.
  4. Now press “Ctrl + V” to paste the location.

Tips & Warnings

  1. This method will not works on Windows XP but it will works on Windows Vista, Windows 7 and Windows 8,8.1

How to create own name File and Folder using context menu

In windows by default you can create “New folder, New folder (2), etc..,”. By this method you can create your own name (custom name) folder EX:“ MDSN, MDSN (2), etc..,”. By this method we can also create our own name file’s using context menu.

1.Creating own name Files.

You can create own name file such as .txt, doc etc..,
Open Registry Editor
Open run command ( windows key + r ).
Type regedit to open Registry Editor.

First create the file you want to change the name
Ex:"New Text Document.txt" form context menu.
Copy the file name "New Text Document".
After that remove text "New" and copy text as "Text Document".
Goto the registry editor and press Ctrl + F to find Text Document in my sytem I found (Default) value "OOXML Text Document" it is different for all system. Keep search the value until you find the exact value.
If you find then rename it to your name or any name.
(Before renaming copy the value. Because if it’s not works then you can restore the name.)
If it's not work do the same steps because mostly all important information are stored in windows registry.

2.Creating own name folder.

First
Download Create own name Folder.BAT.zip
Download Create own name Folder.reg.zip

Unzip the file “Create own name Folder.BAT.zip”  after that open “Create own name Folder.BAT” form notepad.
    
::EX: Inside of  "NAME"=="MOHAMED USHMAN [ MDSN ]"  Edit 3 times inside of "NAME"

::EX: " [ "==" (" ---"{ " 

::EX: " ] "==" )" ---" }" 

::Don't use EX:\ / : * ? " < > |

cmd /c
FOR /L %%A IN (2,+1,100) Do (if exist "NAME" ( MD "NAME"" [ ""%%A"" ]"&&EXIT ) ELSE ( MD "NAME"&&EXIT ) )

   

In the batch file code rename “NAME” to any name EX: “MDSN” 3 times
    
::EX: Inside of  "NAME"=="MOHAMED USHMAN [ MDSN ]"  Edit 3 times inside of "NAME"

::EX: " [ "==" (" ---"{ " 

::EX: " ] "==" )" ---" }" 

::Don't use EX:\ / : * ? " < > |

cmd /c
FOR /L %%A IN (2,+1,100) Do (if exist "MDSN" ( MD "MDSN"" [ ""%%A"" ]"&&EXIT ) ELSE ( MD "MDSN"&&EXIT ) )

   

After that save and run “Create own name Folder.BAT”. If you create your folder successfully then install the “Create own name Folder.reg” file in your system.

Open Registry Editor
Open run command ( windows key + r ).
Type regedit to open Registry Editor.
Navigate to the
 
HKEY_CLASSES_ROOT\Directory\Background\shell\Create own name Folder
Right click on (Default) key value. Then click Modify...
Enter Value Data: MDSN (Any Name)
After that Navigate to the
 
HKEY_CLASSES_ROOT\Directory\Background\shell\Create own name Folder\command
Right click on (Default) key value. Then click Modify...
Enter Value Data: EX:
 
cmd /c FOR /L %%A IN (2,+1,100) Do (if exist "MDSN" ( MD "MDSN"" [ ""%%A"" ]"&&EXIT ) ELSE ( MD "MDSN"&&EXIT ) )










Now you can create own name folder

Video

How to register or unregister OCX & DLL file using administrator cmd & context menu

How to register or unregister OCX & DLL file using administrator cmd & context menu
Using this method you can register DLL and OCX file using Command prompt or by Context menu when you right click on the file. The Command prompt method works on all Windows OS but the context men method works on windows 7 and above version of windows 7 such as windows 8 , 8.1.

For an Example if you installed Windows OS in C:\ drive then follow the steps.
1.If you are using 32 bit Windows OS then past your DLL or OCX file in
C:\Windows\System32

2.If you are using 64 bit Windows OS then past your DLL or OCX file in
C:\Windows\SysWOW64

1.Register from Command prompt

Open Administrator command prompt
for 32 bit os
using admin cmd Ex: regsvr32 C:\Windows\System32\filename.dll

for 64 bit os
using admin cmd Ex: regsvr32 C:\Windows\SysWOW64\filename.dll

2.Register from Context menu

Using this method you can intall DLL or OCX file's form Context menu.

Download OCXDLL.bat.zip copy and past the OCXDLL.bat in C:\ location
Download OCXDLL.reg.zip and install the registry file

1.If you are using 32 bit Windows OS then past your DLL or OCX file in
C:\Windows\System32

2.If you are using 64 bit Windows OS then past your DLL or OCX file in
C:\Windows\SysWOW64

Right click the file after that you can register or unregister OCX & DLL files form context menu.

Download COMDLG32.OCX.zip if you need.

Video

How to create a CLSID to open files or folder from different location

Now you can open files, folders form different location such as My Computer, Control panel, Context menu. By creating CLSID form windows registry, you can create your own CLSID to lunch file and folder form different location(special folders).


1.Open Registry Editor

Open run command ( windows key + r ).
Type regedit to open Registry Editor.

2. Creating class ID

Before creating CLSID you must have to conform that the CLSID is not in the registry. If CLSID is not there means you can create your own CLSID in windows system. , if you find the same CLSID then change it to another name.

Ex: Assume that you’re going to create CLSID “{00000000-0000-0000-0000-000000000001}”.

    
Windows Registry Editor Version 5.00

;explorer.exe /n,/e,/root,C:\\MDSN or c:\\MDSN.txt 

;if you using exe file to open C:\\MDSN.exe

[HKEY_CLASSES_ROOT\CLSID\{00000000-0000-0000-0000-000000000001}]
@="Name"
"InfoTip"="Files and Folders"

[HKEY_CLASSES_ROOT\CLSID\{00000000-0000-0000-0000-000000000001}\DefaultIcon]
@="shell32.dll,7"

[HKEY_CLASSES_ROOT\CLSID\{00000000-0000-0000-0000-000000000001}\InProcServer32]
@="shell32.dll"
"ThreadingModel"="Apartment"

[HKEY_CLASSES_ROOT\CLSID\{00000000-0000-0000-0000-000000000001}\Shell]

[HKEY_CLASSES_ROOT\CLSID\{00000000-0000-0000-0000-000000000001}\Shell\Open]

[HKEY_CLASSES_ROOT\CLSID\{00000000-0000-0000-0000-000000000001}\Shell\Open\Command]
@="msg * Its working"


;MyComputer
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{00000000-0000-0000-0000-000000000001}]


;ControlPanel
;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel\NameSpace\{00000000-0000-0000-0000-000000000001}]


;Desktop
;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{00000000-0000-0000-0000-000000000001}]
    

Download CLSID.reg.zip

3. Add file or folder to CLSID

Using registry editor if you want to change the name of the CLSID then Navigate to
  
HKEY_CLASSES_ROOT\CLSID\{00000000-0000-0000-0000-000000000001}
Edit value name: (Default)= Any Name
After that Navigate to
  
HKEY_CLASSES_ROOT\CLSID\{00000000-0000-0000-0000-000000000001}\Shell\Open\Command

Edit value name: (Default)
for File(Default) =C:\Program Files (x86)\MDSN Welcome\MDSN Welcome.exe
[you can add any type of file Ex: .txt,.doc,etc..,]
for Folder(Default) =explorer.exe /n,/e,/root,C:\MDSN

4.Open file or folder for special folders like MyComputer or ControlPanel

For an Ex if you want to add it to my computer then in CLSID.reg file
Navigate to ; MyComputer ;[HKEY_LOCAL_MACHINE\SO...
(Remove the “; - semicolon” from [HKEY_LOCAL_MACHINE\SO ...)
Save and install CLSID.reg file.

5.Opening form context menu

Follow step 4 to add file or folder to open form context menu
For Desktop only


Windows Registry Editor Version 5.00

;explorer.exe /n,/e,/root,C:\\MDSN or c:\\MDSN.txt

;if you using exe file to open C:\\MDSN.exe

;For Desktop only

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\For Desktop only]
"icon"="shell32.dll,7"
@="For Desktop only"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\For Desktop only\command]
@="msg * Its working"
Download For Desktop only.reg.zip

For all Directorys(Folders)and Desktop

Windows Registry Editor Version 5.00

;explorer.exe /n,/e,/root,C:\\MDSN or c:\\MDSN.txt 

;if you using exe file to open C:\\MDSN.exe

;For all Directorys(Folders)and Desktop

[HKEY_CLASSES_ROOT\Directory\Background\shell\For Folders and Desktop]
"icon"="shell32.dll,7"
@="For Folders and Desktop"

[HKEY_CLASSES_ROOT\Directory\Background\shell\For Folders and Desktop\command]
@="msg * Its working"
Download For all Directorys ( Folders ) and Desktop.reg.zip

Tips & Warnings

  1. Create System restore point because if anything goes wrong then you can restore your system.
  2. If you want to delete the created CLSID then just delete CLSID.( Delete only you created value's because if you delete anything else form registry means it will damage your system.


Video

How to edit context menu ( open ) to custom name for windows folder

Do you want to change the context menu (OPEN) for Folder? This method will help's to change the character in the context menu when you right click on the windows Folder.


How to change context menu ( open ) to custom name for windows folder

Open Registry Editor

Open run command ( windows key + r ).
Type regedit to open Registry Editor.

How to change context menu ( open ) to custom name for windows folder

Navigate to the

  HKEY_CLASSES_ROOT\Folder\shell\open
Right click on (Default) key value. Then click Modify...
Enter Value Data: (Any character EX: Name or Number etc..,)

How to change context menu ( open ) to custom name for windows folder

click ok to perform action.
you can see the name [ Open ] is change to custom name [ MDSN ( Open ) ]

How to change context menu ( open ) to custom name for windows folder

Restore the context menu

If you want to restore the context menu to open.
Navigate to the
HKEY_CLASSES_ROOT\Folder\shell\open
Then Delete the (Default) key.

How to change context menu ( open ) to custom name for windows folder

How to set or create a background image in windows xp folder

How to set or create a background image in windows xp folder
Set background image for Windows XP folder. This method is very useful to set jpg image for windows folder changed easily without any software or application. This method only works on Windows XP and lower version of Windows XP such as Windows 98.


1.Create the folder to change the background.

2.Open the notepad and past the following coding

    
[{BE098140-A513-11D0-A3A4-00C04FD706EC}]
iconarea_image=”image_name.jpg”
iconarea_text=0X00F0F0FF
    

3. Save the file as desktop.ini in the folder.

4.Now go to the Properties by clicking right button on the Folder icon and then click on Customize Tab and then on Change Icon.

5.Now just select any icon and click on the OK button.

some hex code for font color:

    
 0xFF0000 = blue        
 0xFFFF00 = blue light   
 0x000000 = black          
 0xA8A8A8 = gray         
 0x33CC00 = green        
 0xEAADEA = pink        
 0xE10000 = red             
 0xFFFFFF = white        
 0x00FFFF = yellow

Video