#include<stdio.h>
int OR(int,int);
int AND(int,int);
int XOR(int,int);
int NOT(int);
void main()
{
int a,b,ch,o;
printf("\n-:MENU:-\n1.AND\n2.OR\n3.NOT\n4.XOR\n0.Exit\n");
do{
printf("\nEnter Choice:");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf ("\nTruth Table for AND\nA B \tO");
for(a=0;a<=1;a++)
{
for(b=0;b<=1;b++)
{
o=AND(a,b);
printf("\n%d %d \t%d",a,b,o);
}
}
break;
case 2:
printf ("\nTruth Table for OR\nA B \tO");
for(a=0;a<=1;a++)
{
for(b=0;b<=1;b++)
{
o=OR(a,b);
printf("\n%d %d \t%d",a,b,o);
}
}
break;
case 3:
printf ("\nTruth Table for NOT\nA \tO");
for(a=0;a<=1;a++)
{
o=NOT(a);
printf("\n%d \t%d",a,o);
}
break;
case 4:
printf ("\nTruth Table for XOR\nA B \tO");
for(a=0;a<=1;a++)
{
for(b=0;b<=1;b++)
{
o=XOR(a,b);
printf("\n%d %d \t%d",a,b,o);
}
}
break;
case 0: exit();
break;
default: printf("\nError");
}
}while(ch!=0);
}
int OR(int a, int b)
{
if(a==0&&b==0)
return 0;
else
return 1;
}
int AND(int a, int b)
{
if (a==1&&b==1)
return 1;
else
return 0;
}
int NOT(int a)
{
if (a==0)
return 1;
else
return 0;
}
int XOR(int a,int b)
{
if (a==0&&b==1||a==1&&b==0)
return 1;
else
return 0;
}
Friday, May 22, 2015
Thursday, May 21, 2015
Simple Interest
#include<stdio.h>
void main()
{
float p;
float ir,t;
float in;
printf("Principle amount : ");
scanf("%f",&p);
printf("\nInterest : ");
scanf("%f",&ir);
printf("\nTime (in year) : ");
scanf("%f",&t);
in=p*ir*t/100;
printf("\nYou will get interest : Rs. %.2f",in);
}
Output
Principle amount : 5000
Interest : 10
Time (in year) : 3
You will get interest :Rs. 1500.00
Print the Multiplication Table
#include<stdio.h>
void main()
{
int x=1,num,res;
printf("Enter a Number : ");
scanf("%d",&num);
while(x<=10)
{
res=num*x;
printf("\n%d x %d = %d",num,x,res);
x++;
}
}
Output
Enter a Number : 6
6 x 1 = 6
6 x 2 = 12
6 x 3 = 18
6 x 4 = 24
6 x 5 = 30
6 x 6 = 36
6 x 7 = 42
6 x 8 = 48
6 x 9 = 54
6 x 10 = 60
Find the Greatest of Three Numbers
#include<stdio.h>
void main()
{
int x,y,z;
printf("Enter values of x, y and z : ");
scanf("%d,%d,%d",&x,&y,&z);
if(x>=y && x>=z)
printf("\n%d is greatest",x);
else if(y>=z)
printf("\n%d is greatest",y);
else
printf("\n%d is greatest",z);
}
Output
Enter values of x, y and z : 4, 9, 2
9 is greatest
Find Greatest number using Conditional Operator
Sumit Kar May 21, 2015 Basic, Conditional Operator, Tricky No comments
Print "Hello, World!" without semicolon
Solution: 1
#include<stdio.h>Solution: 2
void main(){
if(printf("Hello world")){
}
}
#include<stdio.h>Solution: 3
void main(){
while(!printf("Hello world")){
}
}
#include<stdio.h>
void main(){
switch(printf("Hello world")){
}
}
Output
Hello, World!
Accept Name, Age from User and Print them on the Screen
#include<stdio.h>
int main()
{
char nam[20];
int age;
printf("Enter Your Name : ");
scanf("%s",&nam);
printf("Enter Your Age : ");
scanf("%d",&age);
printf("\nYour Name is %s ",nam);
printf("and your age is %d",age);
return 0;
}
Output
Enter Your Name : Sumit
Enter Your Age : 21
Your Name is Sumit and your age is 21
Thursday, May 14, 2015
Normalization
Sumit Kar May 14, 2015 DBMS, featured, Programming No comments

Normalization is the process of splitting relations into well-structured relations that allow users to insert, delete, and update tuples without introducing database inconsistencies. The focus of normalization is to reduce redundant data to the minimum. Normalization is also called “Bottom-up approach”, because this technique requires very minute details like every participating attribute and how it is dependant on the key attributes, is crucial. If you add new attributes after normalization, it may change the normal form itself.
Through Normalization, the collection of data in a single table is distributed into multiple tables with specific relation. Without normalization many problems can occur when trying to load an integrated conceptual model into the DBMS. These problems arise from relations that are generated directly from user views are called anomalies. There are three types of anomalies:
RollNo | StudentName | CourseNo | CourseName | Instructor |
120 | SKL | CS-75 | DBMS | SB |
89 | KBC | CS-75 | DBMS | SB |
25 | ABC | CS-75 | DBMS | SB |
48 | XYZ | CS-30 | CA | MC |
57 | TKC | CS-80 | OS | JB |
120 | SKL | CS-80 | OS | JB |
Update anomaly: An update anomaly is a data inconsistency that results from data redundancy and a partial update. For example, if there is a change in the name of the instructor for CS-75, we need to make change for all the rows. If we forget to update a single row the database will show two instructor names for the Course CS-75.
Deletion anomaly: This means loss of useful information. In some cases it may occur that some useful data is lost. For example, consider the row for RollNo 48. XYZ is the only student who has opted for CS-30. If XYZ leaves the institute and the data is deleted for XYZ, the associated data for Course will also be deleted.
Insertion anomaly: An insertion anomaly is the inability to add data to the database due to absence of other data. For example, assume that the above table is defined so that null values are not allowed. If a course is added but not immediately students opt for the course, then this course could not be entered into the database (68). This results in database inconsistencies due to omission.
In database tables are normalized for the following reasons:
To allow data retrieval at an optimal speed
Data maintenance through update, insertion and deletion.
To reduce the need to restructure tables for new applications
A functional dependency is a constraint between two sets of attributes in a relation from a database. It occurs when an attribute in a relation uniquely determines another attribute.
In a given relation R, X and Y are attributes. Attribute Y is functionally dependent on attribute X if each value of X determines EXACTLY ONE value of Y, which is represented as X → Y (X can be composite in nature).
We say here “X determines Y” or “y is functionally dependent on x”.
X→Y does not imply Y→X.
If the value of an attribute “Marks” is known then the value of an attribute “Grade” is determined since Marks→ Grade
RollNo | StudentName | Marks | Grade |
59 | ABC | 90 | A |
96 | XYZ | 70 | B |
Types of functional dependencies:
1. Full Functional dependency: X and Y are attributes. X Functionally determines Y (Note: Subset of X should not functionally determine Y)
2. Partial Functional dependency: X and Y are attributes. Attribute Y is partially dependent on the attribute X only if it is dependent on a sub-set of attribute X.
3. Transitive dependency: X Y and Z are three attributes. X -> Y, Y-> Z => X -> Z
Now consider the following Relation
REPORT (STUDENT#, COURSE#, CourseName, IName, Room#, Marks, Grade)
• STUDENT# - Student Number
• COURSE# - Course Number
• CourseName - Course Name
• IName - Name of the Instructor who delivered the course
• Room# - Room number which is assigned to respective Instructor
• Marks - Scored in Course COURSE# by Student STUDENT#
• Grade - obtained by Student STUDENT# in Course COURSE#
The Functional Dependencies are:
• STUDENT# COURSE# → Marks
• COURSE# → CourseName,
• COURSE# → IName (Assuming one course is taught by one and only one
Instructor)
• IName → Room# (Assuming each Instructor has his/her own and non-shared room)
• Marks → Grade
In above example Marks is fully functionally dependent on STUDENT# COURSE# and not on subset of STUDENT# COURSE#. This means Marks cannot be determined either by STUDENT# OR COURSE# alone. It can be determined only using STUDENT# AND COURSE# together. Hence Marks is fully functionally dependent on STUDENT# COURSE#. CourseName is not fully functionally dependent on STUDENT# COURSE# because subset of STUDENT# COURSE# i.e only COURSE# determines the CourseName and STUDENT# does not have any role in deciding CourseName. Hence CourseName is not fully functionally dependent on STUDENT# COURSE#.
Now CourseName, IName, Room# are partially dependent on composite attributes STUDENT# COURSE# because COURSE# alone defines the CourseName, IName, Room#.
Again, Room# depends on IName and in turn IName depends on COURSE#. Hence Room# transitively depends on COURSE#. Similarly Grade depends on Marks, in turn Marks depends on STUDENT# COURSE# hence Grade depends Fully transitively on STUDENT# COURSE#.
Now consider this table:
Student Data | Course Details | Result | |||||
STUDENT# | StudentName | COURSE# | CourseName | IName | Room# | Marks | Grade |
First normal form (1NF)
A relation schema is in 1NF if:
· If and only if all the attributes of the relation R are atomic in nature.
· Atomic: the smallest level to which data may be broken down and remain meaningful.
In relational database design it is not practically possible to have a table which is not in 1NF.
STUDENT# | StudentName | COURSE# | CourseName | IName | Room# | Marks | Grade |
Second normal form (2NF)
A Relation is said to be in Second Normal Form if and only if:
· It is in the First normal form, and
· No partial dependency exists between non-key attributes and key attributes.
An attribute of a relation R that belongs to any key of R is said to be a prime attribute and that which doesn’t is a non-prime attribute To make a table 2NF compliant, we have to remove all the partial dependencies
Note: - All partial dependencies are eliminated
STUDENT# | StudentName |
COURSE# | CourseName | IName | Room# |
STUDENT# | COURSE# | Marks | Grade |
Third normal form (3 NF)
A relation R is said to be in the Third Normal Form (3NF) if and only if:
· It is in 2NF and
· No transitive dependency exists between non-key attributes andkey attributes.
• STUDENT# and COURSE# are the key attributes.
• All other attributes, except grade are nonpartially, non-transitively dependent on key attributes.
STUDENT# | StudentName |
COURSE# | CourseName | IName | Room# |
STUDENT# | COURSE# | Marks |
Marks (Lower Bound) | Marks (Upper Bound) | Grade |
Boyce-Codd Normal form (BCNF)
A relation is said to be in Boyce Codd Normal Form (BCNF)
· If and only if all the determinants are candidate keys.
BCNF relation is a strong 3NF, but not every 3NF relation is BCNF.
Consider the table:
Student# | EmailID | Course# | Marks |
ABC | abc@sumitkar.in | CS-75 | 98 |
Candidate Keys for the relation are [C#, S#] and [C#, Email]. Since Course # is overlapping, it is referred as Overlapping Candidate Key. Valid Functional Dependencies are:
S# → EmailID
EmailID → S#
S#, C# → Marks
C#, EmailID →Marks
Student# | EmailID |
ABC | abc@sumitkar.in |
Student# | Course# | Marks |
ABC | CS-75 | 98 |
Tuesday, May 12, 2015
Earthquake - Do's and Don'ts
Sumit Kar May 12, 2015 Earthquake, featured_slider 1 comment
.jpg)
A. Before an earthquake:
• Follow and advocate local safe building codes for earthquake resistant construction.• Follow and advocate upgrading poorly built structures.
• Make plan and preparation for emergency relief.
• Identify the medical centres, fire fighting stations, police posts and organise relief society of your area.
• Know the electric and water shut off locations in your house.
• Heavy objects, glasses, cutlery should be kept in lower shelves.
• Flower pots should not be kept on the parapet.
B. During an earthquake:
• Keep calm and reassure others.• During the event, the safest place is an open space, away from buildings.
• If you are indoors, take cover under a desk, table, bed or doorways and against inside walls and staircase. Stay away from
glass doors, glass panes, windows or outside doors. Do not rush to go out of the building, to avoid stampede.
• If you are outside, move away from buildings and utility wires.
• Once in the open, stay there till the vibrations stops.
• If you are in a moving vehicle, stop as quickly as possible and stay in the vehicle.
• Free all pets and domestic animals so that they can run outside.
• Do not use candles, matches or other open flames. Put out all fires.
C. After an earthquake:
• Keep stock of drinking water, foodstuff and first-aid equipment in accessible place.• Do not spread and believe rumours.
• Turn on your transistor or television to get the latest information/bulletins and aftershock warnings.
• Provide help to others and develop confidence.
• Attend the injured persons and give them aid, whatever is possible and also inform hospital.
• Be prepared for aftershocks as these may strike.
• Close the valve of kitchen gas stove, if it is on. If it is closed, do not open. Do not use open flames.
• Do not operate electric switches or appliances, if gas leaks are suspected.
• Check water pipes, electric lines and fittings. If damaged, shut off the main valves. Do not touch live wires of electricity.
• If needed, open doors and cup boards carefully as objects may fall.
Via: imd.gov.in
Thursday, May 7, 2015
Now Send mp3 via WhatsApp for Windows Phone
Sumit Kar May 07, 2015 Microsoft, Technology, WhatsApp, Windows No comments
WhatsApp getting ready for Windows 10
Sumit Kar May 07, 2015 Microsoft, Technology, WhatsApp, Windows 1 comment

WhatsApp today released an update for the Beta version. Primarily the update looks like a Bug Fix update. But while Tech enthusiasts dig into the deep, the update suggests that WhatsApp is getting ready for Windows 10.
![]() |
Notification panel for WhatsApp v 2.11.688 on Windows 10 |
![]() |
Notification panel for WhatsApp v 2.12.20 on Windows 10 |
There are four visible changes. Firstly one of the major feature WhatsApp for Windows Phone was missing for a long time. Now we can attach Audio mp3 files and send it via WhatsApp.

Secondly, while sending text there is a cool animation for the chat bubbles. There is another cool new feature to select multiple chats and delete or archive the. And lastly there is a toggle button to enable or disable read receipt in the Privacy Settings.

There is a significant change in the version number. While writing this the Public version is 2.11.688, while the Beta version is 2.12.20. I though this version must have the most awaited calling feature. But there is no trace of calling feature in this version.

The feature with maximum requests is finally here. Hope to see many new cool features soon. Specially the Voice Calling feature.