## Apr 24, 2020

### C program to print given data in ascending order

Ex: What is the logic to print given number in ascending order. How to print given array elements in ascending order. C program to print given  array elements in ascending order.

Program:

#include<stdio.h>
void main()
{
int a[]={5,2,7,1,9,10};
int i,j,temp=0;
/*Find size of array a*/
int length=sizeof(a)/sizeof(a);
//Run loops
for(i=0;i<length;i++)
{
for(j=i+1;j<length;j++)
{
if(a[i]>a[j])
{
/*Use swaping logic*/
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("Data in asending order is = ");
for(i=0;i<length;i++)
printf("%d ",a[i]);
}

Above program shows the following output:

### C program to print given number is even or odd using bitwise AND operator

Ex: How to find given number is even or odd using bitwise AND operator. C program to print given number is even or odd using bitwise AND operator. What is the logic to print given number is even or odd using bitwise  operator.

Input from user:

Enter the number
5

Expected Output:

Given number is Odd

Logic to print given number is even or odd using bitwise operator:

Firstly you need to know how bitwise AND operator works. We can use bitwise AND (&) operator to check given number is even or odd. For example, consider one odd number ( 5 ).  So binary of 5(0101), (5 & 1 = 1). Means least significant of every odd number is 1. Therefore (Odd number & 1) is  always one and also (Even number & 1) is zero.

Below program we will use bitwise AND operator to check whether given number is even or odd.  [if(no & 1)] means if this condition is true then number is odd otherwise number is even. Because List significant Bit(LSB) of every odd number is 1 and even number is 0. Which will shown above.

Program:

#include<stdio.h>
void main()
{
int no;
printf("Enter the number\n");
scanf("%d",&no);
if(no & 1)
printf("Given number is Odd\n");
else
printf("Given number is Even\n");
}

## Apr 23, 2020

### If-Else Statements in C Exercises and Solutions

The if-else statement executes a block of code if a specific condition is true. If the condition is false then it executes another block of code which is shown in below flow chart.

## Apr 11, 2020

### C program to print addition, subtraction, multiplication and division of given two numbers

Ex: Write a C program to print addition,  subtraction, multiplication, division of given two numbers. How to print addition, subtraction, multiplication, division of given two numbers. C program to print addition, subtraction, multiplication, division of given two numbers.

Input from user:
Enter values of a & b: 15  10

Expected output:
Subtraction is: 5
Multiplication is: 150
Division is: 1.0000

### Step by step logic of the given program:

1. Accept input two numbers from user declare variable a & b.

2. Add two numbers and store it in some variable say sum, Subtraction of numbers store in variable sub, multiply  two numbers store it in variable mult and last devide number and store it in float variable div.

3. Print sumsubmult and div on the output screen.

## Program to print addition, subtraction, multiplication and division of given two numbers:

/***program to print addition, multiplication, subtraction and division***/

#include<stdio.h>
void main()
{

int a,b,sum,sub,mult;
float div;//variables declaration

//accept input from user
printf("Enter the value of a & b\n");
scanf("%d%d",&a,&b);

// logic to print addition, subtraction, multiplication and division
sum=a+b;

sub=a-b;

mult=a*b;

div=a/b;

//display subtraction
printf("subtraction is %d\n",sub);

//display multiplication
printf("multiplication is %d\n",mult);

//display division
printf("division is %f",div);

}

Above program shows the following output:

Share your thoughts below in the comment section... :)

### C program to print division of given two numbers

Ex: Write a C program to accept two numbers from user and display division of this two numbers to the output screen.  How to print division of two numbers. C program to print division of two numbers.

Input from user:
Enter the value of a&b:
20 5

Expected output:
division is: 4.0000

Step by step logic of the given program:

1.  Accept two numbers from user declare variable say a & b.

2. Devide the number and store division in float variable c.

3. Print division on the output screen.

Program:

/***C program to print division of two numbers***/

#include<stdio.h>
void main()
{
int a,b;
float c;//declaration of variables

//Get input from user
printf("Enter the value of a and b\n");
scanf("%d%d",&a,&b);

c=a/b;//logic for devide two numbers

printf("division is %f",c);//display division
}

Above program shows the following output:

## Apr 10, 2020

### C program to print subtraction of given two numbers

Ex: Write a C program to print Subtraction of given two number. How to print subtraction of given two numbers. C Program to print subtraction of two numbers.

Input from user:
Enter the value of a and b:
50 20

Expected output:
Subtraction is: 30

### Step by step logic of the given program:

1. Accept two numbers from user declare variables say a and b.

2.subtract b from a(a-b) and store subtraction in variable c.

3. Print Subtraction on the output screen:
printf("Subtraction is %d",c);

## C program to print subtraction of given two numbers :

/***C program to print subtraction of two numbers***/

#include<stdio.h>
void main()
{
int a,b,c;//declear three intiger type variables

//Get input from user
printf("Enter the value of a and b\n");
scanf("%d%d",&a,&b);

c=a-b;//subract b from a

//display subtraction
printf("Subtraction is %d",c);
}

Above program shows the following output:

### Basic C programming exercises and examples with solution

C programming language is easy to learn... Although numerous computer languages are used to write computer applications, the computer programming language C is the most popular language in worldwide.

C programming language is best and interested to know how a computer programs works internally.

If you are beginner or interested in programming or you wan't to learn C programming then codeforhunger is for you.
I am sure you will find these exercises and examples interesting and useful to gain your C programming language knowledge.

Here, we will start from basics to advance. With lot of exercises and examples with there solutions.

## Basic C Programming Exercises and Examples:

Feel Free to share your doubts in the comment section given below... :)

## Apr 8, 2020

### Bitwise operators in C, exercises and examples with solution

In the C Programming language, operations can be performed on a bit level using bitwise operators. We use bitwise operators to manipulate data  at its lowest bit level. bitwise operators works on each bit of the data.

Definition: A bitwise operator is an operator used to perform bitwise operations on bit patterns or binary numerals that involve the manipulation of individual bits.
Bitwise operators are used in communication stack.

### There are six bitwise operators are in C programming:

Above table shows six bitwise operators used in C programming language.

### Bitwise Operators In C:

1. Bitwise AND
2. Bitwise OR
3. Bitwise XOR
4. Bitwise Complement
5. Bitwise left shift
6. Bitwise right shift

For more details about:- bitwise operators .

## Apr 1, 2020

### What are the job's in IT (part-time jobs)

You are now an IT students & also  programmer and you have questions about your future. don't  worry i will give you some information about that. I will clear all your  doubt's. Photo by

## What are the job's in IT?

1. mobile application developer..
2. web developer...
3. information technology vendor manager...
4. software engineer...
5. health IT specialist...
6. IT consultant...
7. Game developer (programming and designing in gaming).

### Which part-time job is best?

If you are a IT student or programmer then Web designing is a best part-time job for you..
You can also do...
• Accountant
• Costumer service
• Sales consultant
• Content writer/Editor
• Home Tutor....
This type of  Jobs you can do with study and college.
If you're a Student my best advise for you is you can focus on programming for better programmer in future.

### What are the best IT Job's?

There are many jobs in IT industry, but some the best jobs are...
• Computer Network Architect...