Sunday, February 24, 2013

C++ Code Of If Else Statements 2


Any character is entered by the user; write a program to determine whether the character entered is a capital letter, a small case letter, a digit or a special symbol.The following table shows the range of ASCII values for various characters.

Characters ASCII Values
A – Z 65 – 90
a – z 97 – 122
0 – 9 48 – 57
special symbols 0 - 47, 58 - 64, 91 - 96, 123 – 127



 

#include<iostream.h>
#include<conio.h>

int main ()
{
 char ch;
 cout<<"Enter any character:";
 cin>>ch;

 if (ch>=65 && ch<=90)
  cout<<"Character is a capital letter";
 else if (ch>=97 && ch<=122)
  cout<<"Character is a small letter";
 else if (ch>=48 && ch<=57)
  cout<<"Character is a digit";
 else if ((ch>0 && ch<=47)||(ch>=58 && ch<=64)||(ch>=91 && ch<=96)||(ch>=123 && ch<=127))
  cout<<"Character is a special symbol";

 getch();
 return 0;
}



**************************************************

Any character is entered by the user; write a program to determine whether the character entered is a capital letter, a small case letter, a digit or a special symbol.The following table shows the range of ASCII values for various characters.




#include<iostream.h>
#include<conio.h>

int main()
{
 float basic_salary, gross_salary, HRA, DA;
 cout<<"Enter basic salary of Employee : ";
 cin>>basic_salary;

 if (basic_salary<1500)
 {
  HRA=0.1*basic_salary;
  DA=0.9*basic_salary;
 }
 else
 { 
  HRA=500;
  DA=0.98*basic_salary;
 }

 gross_salary=basic_salary+HRA+DA;
 cout<<"Gross salary is : "<<gross_salary;

 getch();
 return 0;
}


**************************************************


The marks obtained by a student in 5 different subjects are input by the user. The student gets a division as per the following rules:
Percentage above or equal to 60 - First division
Percentage between 50 and 59 - Second division
Percentage between 40 and 49 - Third division
Percentage less than 40 - Fail
Write a program to calculate the division obtained by the student.




 

#include<iostream.h>
#include<conio.h>

int main()
{
 int sub1,sub2,sub3,sub4,sub5,percentage;
 cout<<"Enter marks of five subjects : ";
 cin>>sub1>>sub2>>sub3>>sub4>>sub5;
 percentage=(sub1+sub2+sub3+sub4+sub5)/5;

 if(percentage>=60)
  cout<<"Ist division";
 else if(percentage>=50)
  cout<<"IInd division";
 else if(percentage>=40)
  cout<<"IIIrd division";
 else
  cout<<"Fail" ;

 getch();
 return 0;
}



C++ Code Of If else Statements 1


Find the absolute value of a number entered by the user.


#include<iostream.h>
#include<conio.h>


int main()
{
 int a;
 cout<<"Enter any number:";
 cin>>a;

 if(a>0)
  cout<<"The absolute value of number is:"<<a;
 else
  cout<<"The absolute value of number is:"<<-(a);

 getch();
 return 0;
}


**********************************************

Write a program to calculate the monthly telephone bills as per the following rule:
Minimum Rs. 200 for upto 100 calls.
Plus Rs. 0.60 per call for next 50 calls.
Plus Rs. 0.50 per call for next 50 calls.
Plus Rs. 0.40 per call for any call beyond 200 calls.




#include<iostream.h>
#include<conio.h>

int main()
{
 int calls;
 float bill;
 cout<<"Enter number of calls : ";
 cin>>calls;

 if(calls<=100)
  bill=200;
 else if (calls>100 && calls<=150)
   {
       calls=calls-100;
       bill=200+(0.60*calls);
 }
 else if (calls>150 && calls<=200)
 {
  calls=calls-150;
  bill=200+(0.60*50)+(0.50*calls);
  }
 else
 {
  calls=calls-200;
  bill=200+(0.60*50)+(0.50*50)+(0.40*calls);
 }

 cout<<" Your bill is Rs."<<bill;

 getch();
 return 0;
}


********************************************

Write a program to find the roots of a quadratic equation of type ax2+bx+c where a is not equal to zero.

#include<iostream.h>
#include<conio.h>
#include<math.h>


int main()
{
 float a,b,c,d,root1,root2;
 cout<<"Enter value of  a, b and c : ";
 cin>>a>>b>>c;

 d=b*b-4*a*c;

 if(d==0)
 {
  root1=(-b)/(2*a);
  root2=root1;
  cout<<"Roots are real & equal";
   }
 else if(d>0)
 {
  root1=-(b+sqrt(d))/(2*a);
  root2=-(b-sqrt(d))/(2*a);
  cout<<"Roots are real & distinct";
 }
 else
 {
  root1=(-b)/(2*a);
  root2=sqrt(-d)/(2*a);
  cout<<"Roots are imaginary";
 }

 cout<<"\nRoot 1= "<<root1<<"\nRoot 2= "<<root2;

 getch();
 return 0;
}

C++ Start Output Programs


Write C++ program to print following pattern:
i)
**********
**********
**********
**********
ii)
*
**
***
****
*****
iii)
        *      
      **  
    ***
  ****
*****
iv)
         *      
       ***
     *****
   *******
 *********
v)
        1
      222
    33333
  4444444
555555555
vi)
        1
      212
    32123
  4321234
543212345


Write a program to print following.




//Solution of (i)
#include<iostream.h>
#include<conio.h>

int main()
{
 int i,j;
 for(i=1;i<=4;i++)
 {
  for(j=1;j<=10;j++)
   cout<<'*';
  cout<<endl;
 }

 getch();
 return 0;
}
***********************************************
//Solution of (ii)
#include<iostream.h>
#include<conio.h>

int main()
{
 int i,j;
 for(i=1;i<=5;i++)
 {
  for(j=1;j<=i;j++)
   cout<<'*';
  cout<<endl;
 }

 getch();
 return 0;
}
***********************************************
//Solution of (iii)
#include<iostream.h> #include<conio.h> int main() { int i,j,k; for(i=1;i<=5;i++) { for(j=5;j>i;j--) cout<<' '; for(k=1;k<=i;k++) cout<<'*'; cout<<endl; } getch(); return 0; }
***********************************************
//Solution of (iv)
#include<iostream.h> #include<conio.h> int main() { int i,j,k; for(i=1;i<=5;i++) { for(j=5;j>i;j--) cout<<' '; for(k=1;k<2*i;k++) cout<<'*'; cout<<endl; } getch(); return 0; }
***********************************************
//Solution of (v)
#include<iostream.h> #include<conio.h> int main() { int i,j,k; for(i=1;i<=5;i++) { for(j=5;j>i;j--) cout<<' '; for(k=1;k<2*i;k++) cout<<i; cout<<endl; } getch(); return 0; }
***********************************************
//Solution of (vi)
#include<iostream.h> #include<conio.h> int main() { int i,j,k,l; for(i=1;i<=5;i++) { for(j=5;j>i;j--) cout<<' '; for(k=i;k>=1;k--) cout<<k; for(l=2;l<=i;l++) cout<<l; cout<<endl; } getch(); return 0; }

C++ Code that display the largest number



Write a program which input three numbers and display the largest number using ternary operator.


#include <iostream.h>
#include <conio.h>

int main()
{
 int a,b,c,greatest;
 cout<<"Enter three numbers : ";
 cin>>a>>b>>c;
 greatest=(a>b&&a>c)?a:(b>c)?b : c;
 cout<<"Greatest number is "<<greatest;

 getch();
 return 0;
}
 

C++ Code accepts a character and display its next character



Write a program which accepts a character and display its next character.


#include<iostream.h>
#include<conio.h>

int main()
{
 char ch;
 cout<< "\nEnter any character : ";
 cin>>ch;
 ch++;
 cout<<"Next character is : "<<ch;

 getch();
 return 0;
}

Saturday, February 23, 2013

C++ Code Of Swap Value without Third Variable



Write a program to swap value of two variables without using third variable


#include<iostream.h>
#include<conio.h>

int main()
{
	int a,b;
	cout<<"\nEnter two numbers : ";
	cin>>a>>b;
	a=a+b;
	b=a-b;
	a=a-b;
	cout<<"\nAfter swapping numbers are : ";
	cout<<a<<" "<<b;

	getch();
	return 0;
}

C++ Code Of Even And Odd Number



Write a program to check whether the given number is even or odd (using ? : ternary operator )


#include<iostream.h>
#include<conio.h>

int main()
{
 int a;
 cout<<"Enter the Number : ";
 cin>>a;
 (a%2==0)?cout<<"Number is even":cout<<"Number is odd";

 getch();
 return 0;
}

C++ Code of Display its ASCII value



Write a program which accepts a character and display its ASCII value.


#include<iostream.h>
#include<conio.h>

int main()
{
 char ch;
 cout<< "\nEnter any character : ";
 cin>>ch;
 cout<<"ASCII equivalent is : "<<(int)ch;

 getch();
 return 0;
}

C++ Code Temperature in Farenheit



Write a program which accept temperature in Farenheit and print it in centigrade.


#include<iostream.h>
#include<conio.h>

int main()
{
 float F,C;
 cout<< "\nEnter temperature in Farenheit : ";
 cin>>F;
 C=5*(F-32)/9;
 cout<<"Temperature in celcius is : "<<C;

 getch();
 return 0;
}

Thursday, February 14, 2013

Data and Database Administration

Data Warehousing

The Internet DatabaseEnvironment

The Client/ServerDatabaseEnvironment

Advanced SQL

Introduction to SQL

Physical DatabaseDesign andPerformance

Logical DatabaseDesign and theRelational Model

The Enhanced ERModel and BusinessRules

Modeling Data in theOrganization

The DatabaseDevelopment Process

The Database Environment

Trees

Trees by


Stacks

Stacks by


Recursion

Queues

Queues by


Link List

Abstract Data Types

Wednesday, February 13, 2013

Windows 2000

The Linux

Security

Protection

Distributes Coordination

Distributed File System

Network Structure

Mass Storage System

I/O Systems

File System Implementation