Showing posts with label Dev Programs. Show all posts
Showing posts with label Dev Programs. Show all posts

Tuesday, 19 January 2016

Write A Program That input salary and tells the Tax USing functions accordin to these rules 1) NO TAX FOR FIRST 1000 2) 5% TAX FOR 2ND 1000 3) 4% TAX FOR THIRD 1000 4) 3% TAX FOR REMAINING SALARY in c++

#include<iostream>
using namespace std;
float tax(long int s);
main()
{int salary;
float Tax;
cout<<"Enter Salary :";
cin>>salary;
Tax=tax(salary);
cout<<"Tax on salary is :"<<Tax;
}
float tax(long int s)
{float tax1;
    if (s<=1000)
    {
tax1=0.0;
    cout<<"NO tax :";
}
else if(s>1000&&s<=2000)
     {
s=s-1000.0;
     tax1=5.0/100.0*1000;
}
else if(s>2000&&s<=3000)
     {
  tax1=5.0/100.0*1000.0;
       s=s-2000.0;
        tax1=tax1+(4.0/100.0*1000.0);
}
else
     {
tax1=5.0/100.0*1000.0;
     tax1=tax1+(4.0/100.0*1000);
     s=s-3000;
     tax1=tax1+(3.0/100.0*s);
     }
return tax1;}

Monday, 11 January 2016

Write A program that Store information of student in Structure including Roll no, Marks, Avg, Grade in Dev c++

#include<iostream>
using namespace std;
struct student
{int rollno;
 int marks;
 float avg;
 char grade;
 };
main()
{ student s;
   cout<<"Enter the information of Student"<<endl<<endl;
   cout<<"Enter Roll NO of student"<<endl;
   cin>>s.rollno;
   cout<<"Enter the Marks"<<endl;
   cin>>s.marks;
   cout<<"Enter avg"<<endl;
   cin>>s.avg;
   cout<<"Enter The Grade OF Student"<<endl;
   cin>>s.grade;
    cout<<"Roll NO of student  "<<s.rollno<<endl;
   cout<<"Marks are = "<<s.marks<<endl;
   cout<<"Avg is = "<<s.avg<<endl;
   cout<<"Grade is  "<<s.grade;
 
}

Thursday, 24 December 2015

Write a program that input an array of n element and sort it in ascending order using bubble sort in c++

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{ int i,j,temp,n;
    cout<<"Enter the size of array";
cin>>n;
int a[n];
cout<<"Enter the elements of array"<<endl;
for(i=0;i<n;i++)
     {
     cin>>a[i];}              
    for(i=0;i<n;i++)
    {
     for(j=0;j<n;j++)
    {
     if(a[i]<a[j])
    {
     temp = a[i];
     a[i] = a[j];
a[j] = temp;}
    }
    }cout<<"Array in ascending order"<<endl;
     for(i=0;i<n;i++)
     cout<<a[i]<<endl;
getch();
}

Tuesday, 22 December 2015

WRITE A PROGRAM THAT INPUT AN ARRAY OF 10 INTEGERS AND TELLS HOW MANY PROME NUMBERS ARE THERE IN THIS ARRAY.

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{ int num,p=0,count=0;
int array[10]={1,2,3,4,5,6,7,8,9,10};
for(int a=0; a<10; a++)
{
for(int c=2;c<=array[a]/2;c++)
{if(array[a]%c==1)
 {
 p=1;
 break;}}
 if(p==0)
 count++;}
 cout<<"PRIME NUMBERS IN ARRAY ARE "<<count;
 getch();

}

Tuesday, 15 December 2015

Write a program that intialize an array of 10 elements and input a integer from user to be searched...using binery search

#include<iostream>
#include<conio.h>
using namespace std;
main()
{
   int arr[10]={10,20,30,40,50,60,70,80,90,100};
   int mid,start,end,loc,n;
   start=0;
   end=9;
   loc=-1;
   cout<<"Enter element to be search  ";
   cin>>n;
   while(start<=end)
   {
        mid=(start+end)/2;
          if(n==arr[mid])
            {
loc=mid;
            break;}
          else if(n<arr[mid])
 end=mid-1;
 else
 start=mid+1;}
 if(loc==-1)
 cout<<"Element not found ";
 else
 cout<<"Element found at "<<loc;
  getch();
}

Write a program that declare an array of 10 elements and input an element n to be searched,,with sequential search

#include<iostream>
#include<conio.h>
using namespace std;
main()
{
   int arr[10]={10,20,30,40,50,60,70,80,90,100};
   int n, loc=-1;
   cout<<"Enter element to be search  ";
   cin>>n;
   for(int a=0; a<n; a++)
   {
      if(n=arr[a])
      loc=a;}
      if(loc==-1)
      cout<<" VAlue not found";
      else
      cout<<" Value found at array "<<loc;
 
   }

Monday, 14 December 2015

Write a program that input two numbers and multiply them using a function

#include<iostream>
#include<conio.h>
using namespace std;
int mul(int x,int y)
{
   return(x*y);
}
main()
{ int a,b;
cout<<"Enter two numbers to multiply"<<endl;
cin>>a>>b;
int res1=mul(a,b);
cout<<"product is "<<res1;
getch();
}

write a program that input two numbers and add them using a function

#include<iostream>
#include<conio.h>
using namespace std;
int sum(int x,int y)
{
   return(x+y);
}
main()
{ int a,b;
cout<<"Enter two numbers to add"<<endl;
cin>>a>>b;
int res1=sum(a,b);
cout<<"Sum is "<<res1;
getch();
}

Saturday, 12 December 2015

WRITE A program that input the name and marks of students of BSCS/IT and dispaly the name of student who got highest marks and show lowest marks with name of student

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{ int max,min,roll1,roll2,n;
cout<<"enter strength of class BSCS/IT = ";
cin>>n;
int marks[n],roll[n];
string name[n],name1,name2;
for(int a=0;a<n;a++)
{  cout<<"enter roll number = "<<endl;
  cin>>roll[a];
  cout<<"enter name of roll number "<<endl;
  cin>>name[a];
  cout<<"Enter marks of  student"<<endl;
  cin>>marks[a];
  max=min=marks[a];}
for(int a=0;a<n;a++)
{
  if(max<marks[a])
 {
  max=marks[a];
  name2=name[a];
  roll2=roll[a];}
if(min>marks[a])
{
 min=marks[a];
 name1=name[a];
 roll1=roll[a];}
}
cout<<name2<<" roll number "<<roll2<<" got maximum marks = "<<max<<endl;
cout<<name1<<" roll number "<<roll1<<" got minimum marks = "<<min;
getch();
}

write a program that input the x,y coordinates for two points and compute the distance between two points using formula Distance= sqrt[(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)]

#include<iostream>
#include<conio.h>
#include<math.h>
using namespace std;
int main()
{ float x1,y1,x2,y2,d;
cout<<"Enter coordinates (x1,y1)"<<endl;
cin>>x1>>y1;
cout<<"Enter coordinates (x2,y2)"<<endl;
cin>>x2>>y2;
d=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
cout<<"distance is = "<<d;
getch();
}

write a program to calculate the volume(v) of a cube by taking measures fro user (formula: v=length*width*height)

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{ float length,width,height,volume;
cout<<"Enter length"<<endl;
cin>>length;
cout<<"Enter width"<<endl;
cin>>width;
cout<<"Enter height"<<endl;
cin>>height;
volume=length*width*height;
cout<<"volume is = "<<volume;
getch();
}

Write a program that find out the area of triangle when three sides a,b,c of triangle are given use appropriat statement to input the value of a,b,c from the keyboard . formula for the area of triangle is area= sqrt[s(s-a)(s-b)(s-c)]

#include<iostream>
#include<conio.h>
#include<math.h>
 using namespace std;
 int main()
 {
     float a,b,c,S,Area;
     cout<<"enter the value of first side:"<<endl;
    cin>>a;
       cout<<"enter the value of second side:"<<endl;
       cin>>b;
         cout<<"enter the value of third side:"<<endl;
         cin>>c;
         S=(a+b+c)/2;
         Area=sqrt(S*(S-a)*(S-b)*(S-c));
         cout<<"The required area = "<<Area;
         getch();
         }

Write a program that inputs basic salary and calculate 35% dearness allowness,25% house rent and then display gross salary in c++

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{ float bSalary;
cout<<"Input Basic salary to know Gross salary with 35% allownace & 25% House rent"<<endl;
//prompt to get salary from user;
cin>>bSalary;
//input into the bSalary;
cout<<"35% allownace is "<<bSalary*.35<<endl;
//35% of your basic salary is bSalary*.35
cout<<"25% House Rent is "<<bSalary*.25<<endl;
//same idea
cout<<"Gross Salary = "<<bSalary*(1-(.35+.25));
/*Gross or take-home salary is your base salary multiplied by one minus of .35 and .25, or .4*/
getch();
}

write a program that input a number and display its table

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{ int n,c;
c=1;
cout<<"Enter a number to get table"<<endl;
cin>>n;
while(c<=10)
{cout<<n<<"*"<<c<<" = "<<n*c<<endl;
c++;
} getch();
}

WRITE a program that show all the possible combination of 123 with nested loop in c++

#include<iostream>
#include<conio.h>
using namespace std;
main ()
{ int i=1,j=1,k=1,l=1;
for(i=1;i<=3;i++)
{for(j=1;j<=3;j++)
{
for(k=1;k<=3;k++)

 cout<<"\t"<<i<<j<<k; }
}
getch();}

write a program that show A-Z alphabets with loop structure in c++

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{ char a;
a='A';
do{ cout<<a<<" "; a++;
} while(a<='Z');
getch();
}

Write a progtam that inputs marks from 0-100 and tells the grade of student with if statement in c++

#include<iostream>
using namespace std;
main()
{ int marks;
cout<<"Enter Marks to know grades"<<endl;
cin>>marks;
if(marks>=80)
cout<<"You have passed with A grade"<<endl;
else if(marks>=70)
cout<<"You have passed with B grade"<<endl;
else if(marks>=60)
cout<<"You have passed with C grade"<<endl;
else if(marks>=50)
cout<<"You have passed with D grade"<<endl;
else if(marks>=40)
cout<<"You have passed with E grade"<<endl;
else
cout<<"You have failed"<<endl;
system("pause");
}

Write a programe that input name from user with spaces and display on screen.

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{string n;
cout<<"enter your name";
getline(cin,n);
cout<<"your name is"<<n;
 getch();

}

Friday, 11 December 2015

Write a program which display Pakistan 5 times with loop structure

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{  int a;
a=1;
do
{ cout<<a<<"=Pakistan"<<endl;
a++;
}while(a<=5); getch();

}

write a program that inputs 10 numbers as elements of array and tells the maximum and minimum number ....c++

#include<iostream>
using namespace std;
main()
{ int array[10],max,min;
cout<<"Enter Array Elements";
for(int a=0;a<10;a++)
cin>>array[a];
max=min=array[0];
for(int a=0;a<10;a++)
{
if(array[a]>max)
{ max=array[a];
}
if(array[a]<min)
min=array[a];
}

cout<<"the greater number is:"<<max<<endl;
cout<<"the minimum number is:"<<min;

}