## What is Logic Gates

##### LOGIC GATES:

The main Objectives is to understand the operation of logic gates.

Logic Gates are used to build digital systems. The basic gates are AND, OR, NOT, NOR, NAND, EXOR and EXNOR gates. NAND and NOR gates are called universal gates as these gates can implement any Boolean function without any use of other gates. The basic operations of gates are explained below with truth table and gate symbol.

AND GATE:

The AND Gate is an electronic circuit which gives high output only when all of its inputs are high, in all other cases output is low. The logical equation for AND gate is

Y=A.B where Y is output and A and B are inputs.The dot (.) symbol is used to indicate AND operation.    Pin Configuration of AND gate

OR GATE:

The OR gate is an electronic circuit, that gives output high when any one or more inputs are high, in all other cases output is low. The logical equation for OR gate is X= A+ B.Where X is output and A and B are inputs.The plus (+) symbol is used to indicate OR operation.    Pin configuration of OR gate

NOT GATE:

The NOT gate is an electronic circuit, that produces output which is inverted version of input. It is also called as inverter. The logical equation for NOT gate is X= ~X.    Pin Configuration of NOT gate

NAND GATE:

The NAND gate is electronic circuit, that gives output low when all of its inputs are high, in all other cases output is high. The logical equation for NAND gate is X= ~ (AB).    Pin configuration of NAND gate.

NOR GATE:

The NOR gate is electronic circuit, which gives output high when all of its inputs are low, in all other cases output is low. The logical equation for NOR gate is Q= ~ (A+B). Where Q is output and A and B are inputs.   Pin Configuration of NOR Gate

XOR GATE:

The XOR gate is electronic circuit, which gives output high only when any one of its input is high, in all other cases output is low. The logical equation for XOR gate is X= A⊕BWhere x is output and A and B are inputs.

The  symbol is used to indicate XOR operation.   Pin Configuration of XOR gate

XNOR GATE:

The XNOR gate is electronic circuit, which gives output high only when all of its inputs are identical, in all other cases output is low. The logical equation for XNOR gate is Y= ~(AxorB)Where Y is output and A and B are inputs.  Logical Symbol of XNOR Gate: Pin Configuration of XNOR gate: ## 555 Timer IC Tutorial : Specification and Pin Diagram

##### What is 555 timer and how will it works ?

So, today we will discuss about the 555 IC. What is 555 timer and how will it works. What is 555 timer IC?

555 timer is introduced in 1972 by signatics corporation.it is usually described as a highly stabled device for generation of accurate delay and oscillation. This is very cheap and popular timing device.
Let’s start a discussion about 555 timer. This is normally an IC (integrated circuit) and also a type of timer. Have you thought about why it’s named as 555 time? The answer is, it made up with THREE 5k ohm RESISTOR in series connection. Let we see how it is working, construction and application. 555 Timer PIN DIAGRAM

Construction of 555 timer:
Once you start studying about IC you don’t go with an IC. First you learn internal diagram of IC. It will helpful for you know where will get an output in which condition and input? Let starts discuss about internal connection.
In introduction itself, I told, 555 timer made of THREE 5k ohm RESISTOR in series connection. Why they would connected in series connection? Because in series connection voltage should be divided.
Based on this three resistors has been connected in series, so voltage divided into 3 parts. The 1st part is VCC/3, 2nd part is 2VCC/3 and last part is 3VCC/3 (refer Fig 1). Fig:1

Then this two voltages (2VCC/3 and VCC/3 ) is connected to the two separate comparator. One is called as a lower comparator and another one is upper comparator. This two comparators will have two terminals are inverting (-) and non- inverting (+). The VCC/3 is connected to non-inverting terminal which in lower comparator. 2VCC/3 is connected to inverting terminal in upper comparator (refer fig 1.1). Next the lower comparator inverted pin goes outside which is the trigger pin 2 of the IC. Upper comparator non-inverting terminal is connected to the Threshold pin 6 of the IC.(refer Fig 1.2) The output of two comparators is giving to the flip flop which is SR FLIP FLOP. On that flip flop have 4 terminals, which are the S,R,Q,Q’. Here we consider Q is an output of SR flip flop and Q’ is an output of 555 timer. So Q’ is connected to the output of IC pin 3. Then Q is connected through the resistor to the PN transistor, the transistor’s VCC pin is a discharge pin.(refer fig 1.3). The reset pin is connected to the SR flip flop. In 2VCC/3 through that control pin has to be connected. (ref Fig 1.4) Working of 555 timer IC:

The 555 timer shown above is configured as an astable circuit. This means that the output voltage is a periodic pulse that alternates between the VCC value and 0 volts. The frequency is the number of pulses per second. The formula to calculate the frequency of the output voltage is:

f=1.44(R1+2R2)C

The period is the time covered for one pulse. This is just the reciprocal of the frequency:

T=1f=0.694(R1+2R2)C

The high time (T1) and low time (T0) can be calculated using the formulas below. Note that the period is the sum of the high time and the low time.

T1=0.694(R1+R2)C

T0=0.694R2C

The mark space ratio is the ratio between the high time and the low time or:

Mark Space Ratio=T1T0

The duty cycle is more commonly used than the mark space ratio. The formula for the duty cycle is:

Duty Cycle=T1T x 100

A 50% duty cycle means the high time is equal to the low time. If an LED is placed at the output of this astable circuit, it will turn on at the same span of time as it is turned off. Note that getting an exact 50% duty cycle is impossible with this circuit.

Notes:

• Increase C to increase the period (reduce the frequency).
• Increase R1 to increase High Time (T1), without affecting the Low Time (T0).
• Increase R2 to increase High Time (T1), increase Low Time (T0) and decrease the duty cycle.

Final result:

Light dimmer using NE555:  These are the final image of 555 timer circuit astable circuit connection and graphical representation of frequency. From this we learned about 555 timer working, construction, and how to calculate the 50% of frequency.

## C Program to Create function pointer

##### Write a C Program to Create Function Pointer ?

In this ongoing C programming tutorial series, we learned many C programming language.In this tutorial, we will learn how to declare a function pointer and what is a function pointer.
A pointer is the backbone of c language, without the pointers, we cannot imagine the C Language. A good cognizance of pointers enables the programmer to indite the optimize and robust code.

In the C language, a pointer is like a variable but only there is one distinction between the pointers and variables. A variable store value but pointer store address of the variable or other pointers.

###### C programming code to create function pointer:

#include<stdio.h>
int sub(int a,int b);
int mul(int a,int b);
int div(int a,int b);
int mode(int a,int b);

struct foo
{
//int a;
int (*ope9r)(int b,int c);

};

int main()
{
int ans,i,j,a,b;
struct foo foo1;
scanf(“%d”,&i);
printf(“enter where u want sub”);
scanf(“%d”,&i);
foo1[i].ope9r=sub;
printf(“enter where u want mul”);
scanf(“%d”,&i);
foo1[i].ope9r=mul;
printf(“enter where u want div”);
scanf(“%d”,&i);
foo1[i].ope9r=div;
printf(“enter where u want mod”);
scanf(“%d”,&i);
foo1[i].ope9r=mode;

printf(“enter the value of a,b”);
scanf(“%d%d”,&a,&b);
printf(“enter the key what u want to perform”);
scanf(“%d”,&j);
//for(j=0;j<5;j++)
ans=foo1[j].ope9r(a,b);

printf(“%d\n”,ans);

return 0;
}

{
return(a+b);
}
int sub(int a,int b)
{
return(a-b);
}
int mul(int a,int b)
{
return(a*b);
}
int div(int a,int b)
{
return(a/b);
}
int mode(int a,int b)
{
return(a%b);
}

## C Program to Generate Multiplication Table

##### Write a C Program to Create Multiplication Table ?

If you are looking for a C program to generate multiplication table.So, In this blog, we will help you to learn and how to write a program for multiplication table in C, and also the logic to print multiplication table of any given number in C program.Just go through this C programming tutorial to learn about multiplication table in C.

Enter any integer number as an input of which you want multiplication table. After that, we use for loop from one to ten to generate multiplication of that number.Inside for loop just multiply numbers and print result in each iteration.Now let’s have a look in a programmatic way

###### C Programming Code to print multiplication table:

#include<stdio.h>
int table( int num )
{
int i,sum=0;
for(num=1;num<=10;num++)
{
for(i=1;i<=10;i++)
{
sum=num*i;
printf(“sum=%d\n”,sum);
}
}
}
int main()
{
int n,table1;

table1=table(n);
return 0;
}

Let us know if you are stuck somewhere and need help.Send us your problem and we will publish the solution,We will try our best to provide you a solution to your problem. You are also free to request some other problem using our comments section.See our more C Programming Language.

## C Program to Print Pyramid

##### Write a C Program to print pyramid ?

Hello friends, we are back with another simple and most interesting C Program.In our last blog we saw you how to write  c program to check whether the number is palindrome or not.In this program we will make a pyramid with the help of C programming Language.This kind of problems is useful for beginners to understands the fundamentals of loops and spaces.
A pattern of numbers, star or characters is a way of arranging these in some logical manner or they may form a sequence. Some of these patterns are triangles which have special importance in mathematics.Let’s see the programming part of this program.

###### C Programming Code to print pyramid:

#include<stdio.h>
int pyramid(int row )
{
int i,j,space=4,c=0;
for ( i=1;i<=row;i++)
{
for (j=1;j<=space;j–)
{
printf(” “);
}

for( j=1;j<=i;j++)
{
printf(“%d”,j);

}
printf(“\n”);
}
return ( row );
}
int main()
{
int line;
printf(“enter the number of lines”);
scanf(“%d”,&line);
pyramid ( line );
return 0;
}

Logic behind this program:

We first take the number of rows in the pattern as input from user using scanf function.
One iteration of outer for loop will print a row of pyramid.
Inner for loop prints the initial spaces for every line and nested while loop prints (2*r – 1) space separated stars for rth row of pyramid.

## C Program to Check the Number is Palindrome or Not

##### Write a C Program to check whether the number is palindrome or not?

What is Palindrome number?
A palindrome is a number that remains the same when its digits are reversed.For example – 1551,121,32423, etc, if these digits are reversed then also we get the same result.The term palindromic is derived from palindrome, which refers to a word (such as rotor or racecar) whose spelling is unchanged when its letters are reversed.
This program reverses an integer (entered by the user) using while loop. Then, if statement is used to check whether the reversed number is equal to the original number or not.

###### C Programming code for Palindrome number or not:

#include<stdio.h>
int integer( int n )
{
int rem,rev=0,a;
a=n;
while( n!=0 )
{
rem=n%10;
rev=rev*10+rem;
n=n/10;
}
if ( a == rev)
{
printf(“%d is a palindrome”,a);
}
else
{
printf(“%d is a not palindrome”,a);
}
}
int main()
{
int num,a;
printf(“enter the num”);
scanf(“%d”,&num);
integer( num );
return 0;
}

Logic behind this program to check number is palindrome or not:

1. Input a number from user. Store it in some variable.
2. Find reverse of the given number. Store it in some variable say reverse.
3. Compare it with the number entered by the user.
4. If both are the same then print palindrome number else print not a palindrome number.

## C Program to Check Vowel or Consonant

##### Write a C Program to find vowel or consonant  using if-else statement?

In English, A, E, I, O, and U are the five alphabets which are known as Vowels.Except these five alphabets all the remaining alphabets are called as consonants. In this tutorial, we will show you, How to write a C Program to check Vowel or Consonant with the explanation.

C Programming Code:
#include<stdio.h>
int main()
{
char alphabet;
int lowercase,highercase;
printf(“enter the charter”);
scanf(“%c”,&alphabet);
lowercase=(alphabet==’a’||alphabet==’e’|| alphabet==’i’||alphabet==’o’||alphabet==’u’);
highercase=(alphabet==’A’||alphabet==’E’|| alphabet==’I’||alphabet==’O’||alphabet==’U’);
if(lowercase||highercase)
{
printf(“%c is vowel\n”,alphabet);
}
else
{
printf(“%c is consonant\n”,alphabet);
}
return 0;
}

Explanation:

The user will first ask to enter any character, and then we are assigning the character to the previously declared variable.
Then, we used the If Else Statement to check whether the character entered by the user is equal to, A, E, I, O, U, for both upper and lower case. And if it is TRUE, it is a Vowel otherwise, it’s a Consonant.

## C Program to Find LCM of Two Number

##### Write a C Program to find lcm of two number ?

Today, let’s learn how to find LCM of two numbers in C Programming Language. But before executing the program, we will see what is LCM.
Least common multiple (LCM) The least common multiple (LCM) of two numbers is the smallest number that they both divide evenly into. In simple language,the smallest positive number that is a multiple of two or more numbers.
for example: ###### Code of the C Program to calculate the LCM of two numbers:

#include
int main()
{
int n1,n2,i,lcm;
printf(“enter the value of n1,n2”);
scanf(“%d %d”,&n1,&n2);
for(i=2;i<=n1 && i<=n2;i++)
{
if(n1%i==0 && n2%i==0)
{
n1=n1/i;
n2=n2/i;
lcm=i;
lcm=lcm*i;
printf(“lcm=%d\n”,lcm);
}
}
printf(“n1=%d,n2%d,lcm=%d\n”,n1,n2,lcm);
return 0;
}

## C Program to Calculate Gross salary

##### Write a C Program to Find Total Salary ?

In our last blog we learn how to write a c program to check whether the number is prime or not.  In this article, we will show you, how to write a C Program to Calculate Gross Salary of an Employee with example.This program will read Basic Salary of an employee, calculate other parts of the salary on percent basic and finally print the Gross Salary of the employee.This was another simple program which has been taught to the beginners.

C Program Code:
#include<stdio.h>
int gross( int basic_salary)
{
int total_salary;
total_salary=basic_salary+.1*basic_salary+.2*basic_salary;
}
int main()
{
int basic_salary,total_salary;
printf(“enter value basic_salary”);
scanf(“%d”,&basic_salary);
total_salary=gross(basic_salary);
printf(“%d=total_salary”,total_salary);
return 0;
}

## C Program to Check the number is prime or not

##### Write a C Program to check whether the number is prime or not?

In our last program, we saw how to calculate profit and loss in c programming. In this program, we will use an if-else statement to check whether the number is prime or not.
A prime number is a positive integer which is divisible only by 1 and itself. For example: 2, 3, 5, 7, 11, 13.When a number has more than two factors then it is called a composite number.

This program takes the number  from the user and then checks whether the input number is prime or not. Then the program displays the result.

C programming code:

#include<stdio.h>
int prime(int num)
{
int i,c=0;
for(i=1;i<=num;i++)
{
if(num%i==0)
{
c++;
}
}
if(c==2)
{
printf(“%d num is prime\n”,num);
}
else
{
printf(“%d num is not prime\n”,num);
}
return (num);
}
int main()
{
int a;
printf(“enter the value of a”);
scanf(“%d”,&a);
prime(a);
printf(“a=%d”,a);
return 0;
}

Let us know if you are stuck somewhere and need help.We will try our best to provide you a solution to your problem. You are also free to request some other problem using our comments section.