ZenTek: February 2014

If You Have Any Problem, Wanna Help, Wanna Write Guest Post, Find Any Error Or Want To Give Us Feedback, Just Feel Free To Contact Us. We Will Reply You Soon.

Name: *

Email: *

Message: *

## C Programming Introduction Examples

Posted By: Haxjer Hunt

## C Program to Swap Two Numbers

This program asks user to enter two numbers and this program will swap the value of these two numbers.

## Source Code to Swap Two Numbers

``````
#include <stdio.h>
int main(){
float a, b, temp;
printf("Enter value of a: ");
scanf("%f",&a);
printf("Enter value of b: ");
scanf("%f",&b);
temp = a;    /* Value of a is stored in variable temp */
a = b;       /* Value of b is stored in variable a */
b = temp;    /* Value of temp(which contains initial value of a) is stored in variable b*/
printf("\nAfter swapping, value of a = %.2f\n", a);
printf("After swapping, value of b = %.2f", b);
return 0;
}
```
```
Output
```
Enter value of a: 1.20
Enter value of b: 2.45

After swapping, value of a = 2.45
After swapping, value of b = 1.2
```

Posted By: Haxjer Hunt

## C Program to Find Size of int, float, double and char of Your System

The size of a character is always 1 byte but, size of int, float and double variables differs from system to system. This program will compute the size of int, float, double and char of you system using sizeof operator. The syntax of size of operator is:

```
temp = sizeof(operand);
/* Here, temp is a variable of type integer,i.e, sizeof() operator
returns integer value. */
```

## Source Code

``````
/* This program computes the size of variable using sizeof operator.*/

#include <stdio.h>
int main(){
int a;
float b;
double c;
char d;
printf("Size of int: %d bytes\n",sizeof(a));
printf("Size of float: %d bytes\n",sizeof(b));
printf("Size of double: %d bytes\n",sizeof(c));
printf("Size of char: %d byte\n",sizeof(d));
return 0;
}``````

Output

```Size of int: 4 bytes
Size of float: 4 bytes
Size of double: 8 bytes
Size of char: 1 byte```

Note: You may get different output depending upon your system.

Explanation

In this program, 4 variables a, b, c and d are declared of type int, float, double and char respectively. Then, the size of these variables is computed using sizeof operator and displayed.

Posted By: Haxjer Hunt

## C Program to Find Quotient and Remainder of Two Integers Entered by User

In this program, user is asked to enter two integers(dividend and divisor) and this program will compute the quotient and remainder and display it.

## Source Code

``````
/* C Program to compute remainder and quotient  */

#include <stdio.h>
int main(){
int dividend, divisor, quotient, remainder;
printf("Enter dividend: ");
scanf("%d",&dividend);
printf("Enter divisor: ");
scanf("%d",&divisor);
quotient=dividend/divisor;           /*  Computes quotient */
remainder=dividend%divisor;          /* Computes remainder */
printf("Quotient = %d\n",quotient);
printf("Remainder = %d",remainder);
return 0;
}``````
Output
```Enter dividend: 25
Enter divisor: 4
Quotient = 6
Remainder = 1
```
Explanation

Posted By: Haxjer Hunt

## C Program to Find ASCII Value of a Character

Every character in C programming is given an integer value to represent it. That integer value is known as ASCII value of that character. For example: ASCII value of 'a' is 97. Here is the complete list of ASCII value of characters in C programming. When a character is stored in variable of type `char`, the ASCII value of character is stored instead of that character itself character itself. For example: If you try to store character 'a' in a char type variable, ASCII value of that character is stored which is 97.
In, this program user is asked to enter a character and this program will display the ASCII value of that character.

## Source Code

``````
/* Source code to find ASCII value of a character entered by user */

#include <stdio.h>
int main(){
char c;
printf("Enter a character: ");
scanf("%c",&c);        /* Takes a character from user */
printf("ASCII value of %c = %d",c,c);
return 0;
}``````
Output
```Enter a character: G
ASCII value of G = 71```
Explanation
In this program, user is asked to enter a character and this character will be stored in variable c, i.e., the ASCII value of that character is stored in variable c. When, this value is displayed using conversion format string %c, the actual variable is displayed but, when this variable is displayed using format string %d, the ASCII value of that character is displayed.

Posted By: Haxjer Hunt

## C Program to Multiply two Floating Point Numbers

In this program, user is asked to enter two floating point numbers and this program will mulitply these two numbers and display it.

## Source Code

``````
/*C program to multiply and display the product of two floating point numbers entered by user. */

#include <stdio.h>
int main( )
{
float num1, num2, product;
printf("Enter two numbers: ");
scanf("%f %f",&num1,&num2);        /* Stores the two floating point numbers entered by user in variable num1 and num2 respectively */
product=num1*num2;  /* Performs multiplication and stores it */
printf("Product: %f",product);
return 0;
}``````

Output

```Enter two numbers: 2.4
1.1
Sum: 2.640000```

Explanation

In this program, user is asked to enter two floating point numbers. These two numbers entered by user will be stored in variables num1 and num2 respectively. This is done using `scanf( )` function. Then, * operator is used for multiplying variables and this value is stored in variable `product`.

Then, the product is displayed and program is terminated.

Posted By: Haxjer Hunt

## C Program to Add Two Integers

In this program, user is asked to enter two integers and this program will add these two integers and display it.

## Source Code

``````
/*C programming source code to add and display the sum of two integers entered by user */

#include <stdio.h>
int main( )
{
int num1, num2, sum;
printf("Enter two integers: ");
scanf("%d %d",&num1,&num2); /* Stores the two integer entered by user in variable num1 and num2 */

sum=num1+num2;      /* Performs addition and stores it in variable sum */
printf("Sum: %d",sum);  /* Displays sum */
return 0;
}``````
Output
```Enter two integers: 12
11
Sum: 23```
Explanation

Posted By: Haxjer Hunt

## Source Code

``````
#include <stdio.h>
int main()
{
int num;
printf("Enter a integer: ");
scanf("%d",&num);  /* Storing a integer entered by user in variable num */
printf("You entered: %d",num);
return 0;
}``````

Output

```Enter a integer: 25
You entered: 25```

Explanation

In this program, a variable num is declared of type integer using keyword `int`. Then, `printf()` function prints the content inside quotation mark which is "Enter a integer: ". Then, the `scanf()` takes integer value from user and stores it in variable num. Finally, the value entered by user is displayed in the screen using `printf()`. Learn more about how `printf()` and `scanf()` works in C programming.

Posted By: Haxjer Hunt

## Source Code

``````
/* C Program to print a sentence. */
#include <stdio.h>
int main()
{
printf("C Programming"); /* printf() prints the content inside quotation */
return 0;
}``````

Output

```
C Programming

```

Explanation

Every C program starts executing code from `main( )` function. Inside main( ), there is a `printf( )` function which prints the content inside the quotation mark which is "C Programming" in this case. Learn more about output in C programming language.

Posted By: Haxjer Hunt

## C Programming Operators

Operators are the symbol which operates on value or a variable. For example: + is a operator to perform addition.

C programming language has wide range of operators to perform various operations. For better understanding of operators, these operators can be classified as:

Operators in C programming
Arithmetic Operators
Increment and Decrement Operators
Assignment Operators
Relational Operators
Logical Operators
Conditional Operators
Bitwise Operators
Special Operators

### Arithmetic Operators

OperatorMeaning of Operator
+addition or unary plus
-subtraction or  unary minus
*multiplication
/division
%remainder after division( modulo division)

Posted By: Haxjer Hunt

## Difference in Increment ++ Operator as Prefix and Postfix

In any programming (Java, C Programming, PHP etc. ), increment ++ and decrement -- operator are used for increasing and decreasing the value of operand by 1 respectively.

```Suppose, a=5 then,
++a;          //a becomes 6
a++;          //a becomes 7
--a;          //a becomes 6
a--;          //a becomes 5```

Simple enough till now but, there is a slight but very important difference that a programmer should remember while using these operators.

## ++ and -- operator as prefix and postfix

If you use ++ operator as prefix like: `++var;` then, the value of operand is increased by 1 then, only it is returned but, if you use ++ as postfix like: `var++;` then, the value of operand is returned first then, only it is increased by 1.

This is demonstrated by an example in these 4 different programming languages.

Posted By: Haxjer Hunt

## Bitwise Operators in C programming

Bitwise operators are special types of operators that are used in programming the processor. In processor, mathematical operations like: addition, subtraction, addition and division are done using the bitwise operators which makes processing faster and saves power.

OperatorsMeaning of operators
&Bitwise AND
|Bitwise OR
^Bitwise exclusive OR
~Bitwise complement
<<Shift left
>>Shift right

## Bitwise AND operator in C programming.

Posted By: Haxjer Hunt

## C Programming Pointers

Pointers are the powerful feature of C and (C++) programming, which differs it from other popular programming languages like: java and Visual Basic.
Pointers are used in C program to access the memory and manipulate the address.

### Reference operator(&)

If var is a variable then, `&var` is the address in memory.
``````
/* Example to demonstrate use of reference operator in C programming. */
#include <stdio.h>
int main(){
int var=5;
printf("Value: %d\n",var);
printf("Address: %d",&var);  //Notice, the ampersand(&) before var.
return 0;
}``````
Output
```Value: 5
Note: You may obtain different value of address while using this code.
In above source code, value 5 is stored in the memory location 2686778. var is just the name given to that location.
You, have already used reference operator in C program while using `scanf()` function.
`scanf("%d",&var);`

### Reference operator(*) and Pointer variables

Posted By: Haxjer Hunt

## C Programming Input Output (I/O)

ANSI standard has defined many library functions for input and output in C language. Functions `printf()` and `scanf()` are the most commonly used to display out and take input respectively. Let us consider an example:
``````
#include <stdio.h>      //This is needed to run printf() function.
int main()
{
printf("C Programming");  //displays the content inside quotation
return 0;
}```
```
Output
`C Programming`
Explanation of How this program works
1. Every program starts from main() function.
2. `printf()` is a library function to display output which only works if `#include<stdio.h>`is included at the beginning.
3. Here, `stdio.h` is a header file (standard input output header file) and `#include` is command to paste the code from the header file when necessary. When compiler encounters `printf()` function and doesn't find `stdio.h` header file, compiler shows error.
4. Code `return 0;` indicates the end of program. You can ignore this statement but, it is good programming practice to use `return 0;`.

## I/O of integers in C

Posted By: Haxjer Hunt

## C Programming Data Types

In C, variable(data) should be declared before it can be used in program. Data types are the keywords, which are used for assigning a type to a variable.

## Data types in C

1. Fundamental Data Types
• Integer types
• Floating Type
• Character types
2. Derived Data Types
• Arrays
• Pointers
• Structures
• Enumeration

## Syntax for declaration of a variable

```data_type variable_name;

```

### Integer data types

Posted By: Haxjer Hunt

## C Program to Demonstrate the Working of Keyword long

Keyword long is used for altering the size of data type. For example: the size of `int` is either 2 bytes or 4 bytes but, when long keyword is used, the size of `long int` will be either 4 bytes or 8 bytes. Also, you can use` long long int`. The size of `long long int` is generally 8 bytes. This program will demonstrate the size of keyword long for my system. It may be different in your system.

## Source Code

``````
#include <stdio.h>
int main(){
int a;
long int b;                /* int is optional. */
long long int c;            /* int is optional. */
printf("Size of int = %d bytes\n",sizeof(a));
printf("Size of long int = %ld bytes\n",sizeof(b));
printf("Size of long long int = %ld bytes",sizeof(c));
return 0;
}``````
```` `
Output```
```Size of int = 4 bytes
Size of long int = 4 bytes
Size of long long int = 8 bytes```
In this program, the sizeof operator is used for finding the size of `int`, `long int` and `long long int`.
Thus, `int` and `long int` for my system can hold values from -231 to 231-1. If I have to work on data outside this range, I have to use `long long int`, which can hold values from -263 to 263-1 .
Similarly, the long keyword can be used double and floats types.

Posted By: Haxjer Hunt

## ASCII Character Codes

 0 1 2 3 4 5 6 7 8 9 0 nul soh stx etx eot enq ack bel bs ht 1 nl vt np cr so si dle dcl dc2 dc3 2 dc4 nak syn etb can em sub esc fs gs 3 rs us sp ! " # \$ % & ' 4 ( ) * + , - . / 0 1 5 2 3 4 5 6 7 8 9 : ; 6 < = > ? @ A B C D E 7 F G H I J K L M N O 8 P Q R S T U V W X Y 9 Z [ \ ] ^ _ ' a b c 10 d e f g h i j k l m 11 n o p q r s t u v w 12 x y z { | } ~ del

## How to use ASCII character code table

Suppose you want to find the ASCII code for capital A then, first watch the corresponding bold number in left of it, i.e, 6 in this case and the bold number on the top of it, i.e, 5. Then,
ASCII value of 'A' equals to 65

Posted By: Haxjer Hunt

## Variables

Variables are memory location in computer's memory to store data. To indicate the memory location, each variable should be given a unique name called identifier. Variable names are just the symbolic representation of a memory location. Examples of variable name: sum, car_no, count etc.

```int num;
```
Here, num is a variable of integer type.

### Rules for writing variable name in C

1. Variable name can be composed of letters (both uppercase and lowercase letters), digits and underscore '_' only.
2. The first letter of a variable should be either a letter or an underscore. But, it is discouraged to start variable name with an underscore though it is legal. It is because, variable name that starts with underscore can conflict with system names and compiler may complain.
3. There is no rule for the length of length of a variable. However, the first 31 characters of  a variable are discriminated by the compiler. So, the first 31 letters of two variables in a program should be different.
In C programming, you have to declare variable before using it in the program.

## Constants

Constants are the terms that can't be changed during the execution of a program. For example: 1, 2.5, "Programming is easy." etc. In C, constants can be classified as:

Posted By: Haxjer Hunt

## C Programming Enumeration

Enumeration type allows programmer to define their own data type . Keyword `enum` is used to defined enumerated data type.
`enum type_name{ value1, value2,...,valueN };`
Here, type_name is the name of enumerated data type or tag. And value1, value2,....,valueN are values of type type_name.
By default, value1 will be equal to 0, value2 will be 1 and so on but, the programmer can change the default value as below:
```enum suit{
club=0;
diamonds=10;
hearts=20;
};```

## Declaration of enumerated variable

Posted By: Haxjer Hunt

## Character set

Character set are the set of alphabets, letters and some special characters that are valid in C language.
Alphabets:
Uppercase: A B C  ....................................  X Y Z
Lowercase: a b c  ......................................  x y z
Digits:
0 1 2 3 4 5 6  8 9
Special Characters:
 , < > . _ ( ) ; \$ : % [ ] # ? ' & { } " ^ ! * / | - \ ~ +
White space Characters:
blank space, new line, horizontal tab, carriage return and form feed

## Keywords:

Keywords are the reserved words used in programming. Each keywords has fixed meaning and that cannot be changed by user. For example:
`int money;`
Here, int is a keyword that indicates, 'money' is of type integer.
As, C programming is case sensitive, all keywords must be written in lowercase. Here is the list of all keywords predefined by ASCII C.

Posted By: Haxjer Hunt

## Facebook Buying WhatsApp For \$19B, Will Keep The Messaging Service Independent

Facebook is purchasing messaging giant WhatsApp for \$16 billion in cash and stock, according to a regulatory filing. The deal is being cut for \$12 billion in Facebook shares, \$4 billion in cash and an additional \$3 billion in RSUs for employee retention.
A termination fee is attached to the deal that would cost Facebook \$1 billion in cash and \$1 billion in shares if the deal fails to pass regulatory muster.
Facebook has posted on its blog, detailing the reasoning behind the acquisition, as well. The post notes that WhatsApp will continue to operate independently and retain its brand. In addition, WhatsApp co-founder and CEO Jan Koum will join Facebook’s board.
Facebook notes that WhatsApp has over 450 million MAUs, with 70 percent of those active each day. In a staggering comparison, Facebook also notes that the messaging volume of WhatsApp approaches the SMS volume of the entire global telecom industry — and that it’s adding 1 million users a day.
“WhatsApp is on a path to connect 1 billion people. The services that reach that milestone are all incredibly valuable,” said Mark Zuckerberg, Facebook founder and CEO in a statement.

Posted By: Akash

## Floating Facebook Like Box Widget For Your Website

Are you struggling to get more facebook likes? Add a floating facebook like box to your blog or website.  The widget remains in a fixed position on the right-hand side of your site.  When you hover over the blue facebook image, the like box will then slide and reveal itself using jquery.

### View Demo

You can see a demonstration of this facebook widget on the right side of this page. Hover over the facebook image with your mouse. A facebook like box should appear.

Posted By: Haxjer Hunt

## Facebook Popup (Like Box Widget)

Add the following code anywhere in the body section of your template. Or simply click the "add to blogger" button for blogspot blogs.  For Wordpress themes, Weebly templates, and Tumblr, you will

Posted By: Haxjer Hunt

## What is HTTPS and Why Should I Care?

HTTPS, the lock icon in the address bar, an encrypted website connection — it’s known as many things. Knowing what it means is important, as it has serious implications banking online, shopping, and avoiding phishing.
When you connect to most websites, your web browser uses the standard HTTP protocol. HTTPS is the secure, encrypted counterpart to HTTP — it literally stands for “HTTP Secure,” which is “Hypertext Transfer Protocol Secure.”

### The Problem With HTTP

Posted By: Haxjer Hunt

## 5 Serious Problems with HTTPS and SSL Security on the Web

HTTPS, which uses SSL, provides identity verification and security, so you know you’re connected to the correct website and no one can eavesdrop on you. That’s the theory, anyway. In practice, SSL on the web is kind of a mess.
This doesn’t mean that HTTPS and SSL encryption are worthless, as they’re definitely much better than using unencrypted HTTP connections. Even in a worst case scenario, a compromised HTTPS connection will only be as insecure as an HTTP connection.

### The Sheer Number of Certificate Authorities

Posted By: Haxjer Hunt

## How to remove "Subscribe to: Posts (Atom)"

If you want to completely remove (or temporarily hide) "Subscribe to: Posts (Atom)", read on.

Ok. Luckily, removing this is quite easy. I hope you know what is it...the Atom thing. It's an easy way for your readers to subscribe to your Blog posts. It's really the same thing like you can see in 90% of blogs, but under the name of RSS (Really Simple Sindication).

Anyway, it's good to have a subscription option, but Feedburner will help you with creating the best one.

1. Hiding To hide it, you just have to insert one part of the code (CSS style in fact..). Go to:
DASHBOARD -- LAYOUT -- EDIT HTML, and find insert the part in purpule, ABOVE the part in green:
.feed-links { display:none; }

2. Removing (deleting)
Before you do anything, back-up your template. Just in case. Then go to:

DASHBOARD -- LAYOUT -- EDIT HTML -- hit EXPAND WIDGET TEMPLATES
then CTRL + F (Option +F) to find the following line of code:

You have to delete that line. Save the template. View blog. And...smile!
How to remove "Subscribe to: Posts (Atom)"

Posted By: Haxjer Hunt

Name

Email *

Message *

Hello Guys

I am an IT(Information Technology) Student design this blog for your Preference I always enjoyed technical things as a kid

now here i am sharing my knowledge about Tips and Tricks In Internet PC Windows Free Recharges and Other Cool Stuffs Too

So enjoy it