Page

Showing posts with label C program. Show all posts
Showing posts with label C program. Show all posts

Thursday, 4 June 2020

program to find gross salary//c project mania//luv yadav

#include<stdio.h>
#include<conio.h>
void main()
{
 float bs,gs,da,hra;
 clrscr();
 printf("Enter basic salary:-");
 scanf("%f",&bs);
 if(bs<=1500)
 {
  hra=bs*10/100;
  da=bs*90/100;
 }
 else
 {
  hra=500;
  da=bs*98/100;
 }
  gs=bs+hra+da;
  printf("gross salary=Rs.%f\n",gs);
  getch();
}

  output of the program is given below:-

  https://youtu.be/tzYRs3ojq6Y

program toprint hello using while//lead to tech//cproject mania

#include<stdio.h>
#include<conio.h>
void main()
{
 clrscr();
 while(!printf("hello to c"))
 {

 }
 getch();
}

 for program and output of the program click on link:-
  
  https://youtu.be/aiF8fF63OrU

Tuesday, 2 April 2019

ques.1. given a point (x,y), write a program to find out if it lies on the x axis, y axis or on the origin||lead to tech||luv yadav||

/*ques.1. given a point (x,y), write a program to find
out if it lies on the x axis, y axis or on the origin*/


#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int x, y;
printf("enter the value of x:\n");
scanf("%d",&x);
printf("Enter the value of y:\n");
scanf("%d",&y);
if(x==0)
printf("value is on y axis\n");
else
{
 if(y==0)
 printf("value is on x axis:\n");
 else
 {
 if(x,y=0)
 printf("point is on origin:\n");
 else
 printf("your point is on graph:\n");
 }
}
getch();
return 0;
}






by luv yadav

Sunday, 31 March 2019

program for three points on straight line||luv yadav||


/*given three points (x1,y1), (x2,y2)and (x3,y3), write a program
 to chek if all the three points fall on one straight line*/
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int x1,x2,x3,y1,y2,y3,t;
printf("x1:");
scanf("%d",&x1);
printf("x2:");
scanf("%d",&x2);
printf("x3:");
scanf("%d",&x3);
printf("y1:");
scanf("%d",&y1);
printf("y2:");
scanf("%d",&y2);
printf("y3:");
scanf("%d",&y3);
t=(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2));
if(t==0)
{
printf("this points present om straight line:");
}
else
{
printf("this point does not lie on straight line:");
}
getch();
return(0);
}




by luv yadav

Monday, 18 March 2019

program for factorial in while loop||luv yadav||


#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
void main()
{
system("cls");
int i, num, fact = 1;
cout<<"\nEnter integer:";
cin>>num;
i=num;
while(num)
{
 fact *= num;
       --num;
}
cout<<"the factorial of"<<i
    <<"is"<<fact<<"\n";
getch();
}



The above program inputs an integer num. Then as long as num is nonzero (according to while (num)) the loop body iterates i.e., fact is multiplied with num and the result is stored back in fact, followed by the decrement of num. Again the test-expression (num) is evaluated : if it is true, the loop is repeated otherwise terminated.
   The for and while loops are entry-controlled loops i.e., there is control over entry in them. Then test-expression is evaluated before entering into the loop, if it is evaluates to true then loop is executed otherwise is loop is terminated.



by luv yadav

Saturday, 22 September 2018

program for deletion a program in c

#include<stdio.h>
#include<conio.h>
void main()
{
int a[100], pos ,i ,n ;
clrscr();
printf("enter no. of element in array\n");
scanf("%d", &n);
printf("\n enter %d element ",n);
for (i=0;i<n;i++)
scanf("%d",&a[i]) ;
printf("\n enter location where you want to delete element ");
scanf("%d",&pos) ;
if (pos >= n+1)
printf("\n deletion not possible");
else
{
for (i=pos-1;i<n;i++)
a[i]=a[i+1];
printf ("\n resultant array ");
for (i=0;i<n-1;i++)
printf("%d\n",a[i]) ;
}
getch ();
}




Wednesday, 19 September 2018

program for printing matrix in c

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a[100][100],n,m,i,j;
printf("enter the number of rows:");
scanf("%d",&n);
printf("enter the number of column:");
scanf("%d",&m);
printf("Enter the number of matrix:\n");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("\nMatrix is:\n");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
printf("\t%d",a[i][j]);
}
printf("\n");
}
getch();
}





                                                                  created by LUV YADAV

Saturday, 15 September 2018

program for finding sum of even and odd natural number

#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int n,sum_even = 0, sum_odd = 0, ctr=1;
cout<<"uptu which natural number:";
cin>>n;
while(ctr <=n)
{
 if(ctr % 2 ==0)
 sum_even += ctr;
 else
 sum_odd+= ctr;
 ctr++;
}
cout<<"\n"<<"the sum of even integer is:"<< sum_even;
cout<<"\n"<<"the sum of odd integer is:"<< sum_odd;
getch();
return(0);
}



Thursday, 13 September 2018

program for reverse in c

#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
clrscr();
char str[100];
printf("enter the name\n");
scanf("%s",&str);
strrev(str);
printf("your name is:");
printf("%s",str);
getch();
return(0);
}



Monday, 10 September 2018

program for two row matrix in c

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a[100],b[100],c[100],i,n;
printf("\nhow many elements in the array:\n");
scanf("%d",&n);
printf("\nenter the elements in the first matrix:\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\nEnter the elements in the second matrix:\n");
for(i=0;i<n;i++)
{
scanf("%d",&b[i]);
}
printf("\nfirst matrix is\n");
for(i=0;i<n;i++)
{
printf("\t%d",a[i]);
}
printf("\nsecond matrix is\n");
for(i=0;i<n;i++)
{
printf("\t%d",b[i]);
}
for(i=0;i<n;i++)
c[i]=a[i]+b[i];
printf("\nSum of both row matrix is\n");
for(i=0;i<n;i++)
{
printf("\t%d",c[i]);
}
getch();
}




Wednesday, 5 September 2018

program for row matrix in c

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a[100],i,n;
printf("How many elements in the array:");
scanf("%d",&n);
printf("Enter the elements");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\n Row matrix is:");
for(i=0;i<n;i++)
{
printf("\t%d",a[i]);
}
getch();
}




program for column matrix in c

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a[100],i,n;
printf("How many elements in the array:");
scanf("%d",&n);
printf("Enter the elements");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\n column matrix is:");
for(i=0;i<n;i++)
{
printf("\n%d",a[i]);
}
getch();
}



Monday, 3 September 2018

program for book information in c

#include<stdio.h>
#include<conio.h>
struct book
{
int b_num;
char a_name[30],publish[40];
float rate;
};
struct book z;
int main()
{
clrscr();
printf("\n enter the year of publication:");
scanf("%d",&z.b_num);
printf("\n enter the name of the author:");
scanf("%s",&z.a_name);
printf("\n enter the name of the publisher:");
scanf("%s",&z.publish);
printf("\n enter the price of the book:");
scanf("%f",&z.rate);
printf("\n....................");
printf("\n Book Information");
printf("\n....................");
printf("\n Book publish in=%d",z.b_num);
printf("\n Author name=%s",z.a_name);
printf("\n Publisher=%s",z.publish);
printf("\n price of the book=%f",z.rate);
printf("\n....................");
getch();
return(0);
}




Thursday, 30 August 2018

program of equation

#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int x,y,equat;
printf("enter the value of x:");
scanf("%d",&x);
printf("enter the value of y:");
scanf("%d",&y);
(equat=((x*x)*(y*y)*(x+y)/(x*x*x*x+y*y*y*y*y*y*y*y*y*y)*(x+y)));
printf("the required value is:");
printf("%d",equat);
getch();
return(0);
}








program to deletion a number from a array

#include<stdio.h>
#include<conio.h>
void main()
{
int a[100], pos ,i ,n ;
clrscr();
printf("enter no. of element in array\n");
scanf("%d", &n);
printf("\n enter %d element ",n);
for (i=0;i<n;i++)
scanf("%d",&a[i]) ;
printf("\n enter location where you want to delete element ");
scanf("%d",&pos) ;
if (pos >= n+1)
printf("\n deletion not possible");
else
{
for (i=pos-1;i<n;i++)
a[i]=a[i+1];
printf ("\n resultant array ");
for (i=0;i<n-1;i++)
printf("%d\n",a[i]) ;
}
getch ();
}




program for insertion a number in array

#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,num,pos,a[10];
clrscr();
printf("enter no of element in array \n");
scanf("%d",&n);
for (i=0;i<n;i++)
{
printf("\n enter element ");
scanf("%d",&a[i]);
}
printf("\n enter no. to be inserted ");
scanf("%d",&num);
printf("\n enter position of array ");
scanf("%d",&pos);
for (i=n;i>=pos;i--)
{
a[i+1] = a[i];
}
a[pos] = num;
n++;
printf("\n after insertion");
for (i=0;i<n;i++)
{
printf("%d",a[i]);
}
getch();
}



Tuesday, 28 August 2018

program of sum of even odd

#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int n,sum_even = 0, sum_odd = 0, ctr=1;
cout<<"uptu which natural number:";
cin>>n;
while(ctr <=n)
{
 if(ctr % 2 ==0)
 sum_even += ctr;
 else
 sum_odd+= ctr;
 ctr++;
}
cout<<"\n"<<"the sum of even integer is:"<< sum_even;
cout<<"\n"<<"the sum of odd integer is:"<< sum_odd;
getch();
return(0);
}



Monday, 27 August 2018

program of factorial

#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int i, num, fact = 1;
cout<<"enter integer:";
cin>>num;
i=num;
while(num)
{
fact*=num;
    --num;
}
cout<<"the factorial of:"<<i<<"is:"<<fact<<"\n";
getch();
return(0);
}

   


Saturday, 18 August 2018

program to display a menu regarding rectangle

#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<math.h>
int main()
{
clrscr();
char ch,ch1;
float l,b,peri,area,diag;
cout<<"\nRectangle menu";
cout<<"\n 1.area";
cout<<"\n 2.perimeter";
cout<<"\n 3.diagonal";
cout<<"\n 4.exit"<<"\n";
cout<<"enter your choice:";
do
{
cin>>ch;
if(ch=='1'|| ch=='2'||ch=='3')
{ cout<<"enter length & breadth:";
cin>>l>>b;
}
switch(ch)
{ case '1': area = l*b;
    cout<<"area="<<area;
    break ;
  case '2': peri = 2*(l+b);
    cout<<"perimeter="<<peri;
    break ;
  case '3': diag =((l*l)+(b*b));
    cout<<"diagnol="<<diag;
    break ;
  case '4': cout<<"breaking";
    exit(0);
  default : cout<<"wrog choice!!!!";
    cout<<"enter a valid one";
    break;
  } // end of switch.
  cout<<"\n want to enter more(y/n)?";
  cin>>ch1;
  if(ch1=='y'|| ch1=='y')
   cout<<"again enter your choice(1-4):";
   } while(ch1=='y'||ch1=='y'); //end of do-while loop
   return (0);
}





Sunday, 17 June 2018

program to find the (a-b)2

#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,identity;
cout<<"enter the value a:";
cin>>a;
cout<<"enter the value b:";
cin>>.b;
identity = (a * a) + (b*b)-(2*a*b);
cout<<"the required value is:";
cout<<identity;
getch();
return(0);
}