Posts

Showing posts from May, 2015

Commonly Asked Interview Questions

Note :  All the programs are tested under Turbo C/C++ compilers and it is assumed that, Programs run under DOS environment, The underlying machine is an x86 system, Program is compiled using Turbo C/C++ compiler. The program output may depend on the information based on this assumptions (for example sizeof(int) == 2 may be assumed).  Predict the output or error(s) for the following: void main() { int const * p=5; printf("%d",++(*p)); }     Answer     Compiler error: Cannot modify a constant value. Explanation p is a pointer to a "constant integer". But we tried to change the value of the "constant integer". void main() { int const * p=5; printf("%d",++(*p)); }     Answer     Compiler error: Cannot modify a constant value. Explanation p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".

Print the Truth Table

#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\

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   Print   Download Code 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   Print   Download Code 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   Print   Download Code Output Enter values of x, y and z : 4, 9, 2 9 is greatest

Find Greatest number using Conditional Operator

#include<stdio.h> void main() { int n1,n2,n3; printf("Enter Numbers (n1 n2 n3) : "); scanf("%d %d %d",&n1,&n2,&n3); printf("Greatest= %d",n1>n2?n1>n3?n1:n3:n2>n3?n2:n3); } Output   Print   Download Code Output Enter Numbers (n1 n2 n3) : 4 9 2 Greatest= 9

Print 1 to 10 using For Loop

#include<stdio.h> int main() { int x=1; for(x=1; x<=10; x++) printf("\n%d",x); return 0; } Output   Print   Download Code Output 1 2 3 4 5 6 7 8 9 10

Print 1 to 10 using While Loop

#include<stdio.h> #include<conio.h> int main() { int x=1; while(x<=10) { printf("\n%d",x); x++; } getch(); return 0; } Output   Print   Download Code Output 1 2 3 4 5 6 7 8 9 10

Swap two Numbers

#include<stdio.h> void main() { int x,y,z; printf("Enter Values x and y : "); scanf("%d%d",&x,&y); z=y; y=x; x=z; printf("\nValue of x=%d",x); printf("\nValue of y=%d",y); } Output   Print   Download Code Output Enter Values x and y : 5 4 Value of x= 4 Value of y= 5

Sum of two numbers

#include<stdio.h> void main() { int a,b,sum; printf("Enter Numbers a and b : "); scanf("%d %d",&a,&b); sum=a+b; printf("\n%d + %d = %d",a,b,sum); } Output   Print   Download Code Output Enter Numbers a and b :5 4 5 + 4 = 9

Print "Hello, World!" without semicolon

Solution: 1 #include<stdio.h> void main(){ if(printf("Hello world")){ } } Solution: 2 #include<stdio.h> void main(){ while(!printf("Hello world")){ } } Solution: 3 #include<stdio.h> void main(){ switch(printf("Hello world")){ } } Output   Print   Download Code Output Hello, World!

Print "Hello, World!"

#include<stdio.h> int main() { printf("\nHello, World! "); return 0; } Output   Print   Download Code 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   Print   Download Code Output Enter Your Name : Sumit Enter Your Age : 21 Your Name is Sumit and your age is 21
Image
Print PDF

Normalization

Image
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-7

Earthquake - Do's and Don'ts

Image
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 stop

Now Send mp3 via WhatsApp for Windows Phone

Image