Page

Showing posts with label Cplusplus. Show all posts
Showing posts with label Cplusplus. 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

Wednesday, 3 July 2019

simple animation program in c++||lead to tech||luv yadav

#include <stdio.h>
#include <conio.h>
#include <graphics.h>
#include <dos.h>

int main() {
/* request auto detection */
int gdriver = DETECT, gmode, err;
int i, j, x, y, top[2], bot[2];

/* initialize graphic mode */
initgraph(&gdriver, &gmode, "C:/TURBOC3/BGI");
err = graphresult();

if (err != grOk) {
/* error occurred */
printf("Graphics Error: %s",
grapherrormsg(err));
return 0;
}

x = 75;
y = getmaxy() / 2 - 100;

for (i = 0; i < 10; i++) {
/* draw the police (shooter) */
setcolor(YELLOW);
setlinestyle(SOLID_LINE, 1, 3);
setfillstyle(SOLID_FILL, YELLOW);

/* drawing head of shooter */
circle(x, y, 15);
floodfill(x, y, YELLOW);

/* drawing body */
setcolor(GREEN);
line(x, y + 20, x, y + 80);

/* leg design */
line(x, y + 80, x - 25, y + 125);
line(x, y + 80, x + 25, y + 125);

/* hand design */
line(x, y + 20, x - 30, y + 40);
line(x - 30, y + 40, x - 38, y + 55);
line(x, y + 20, x + 55, y + 5);

/* gun design */
rectangle(x + 45, y - 5, x + 52, y + 15);
rectangle(x + 45, y - 5, x + 75, y + 2);
arc(x + 52, y + 3, 270, 360, 6);
delay(300);

/* target */
setcolor(YELLOW);
setfillstyle(SOLID_FILL, YELLOW);

/* head of target */
circle(getmaxx() - 70, y, 15);
floodfill(getmaxx() - 70, y, YELLOW);

setcolor(WHITE);
/* body of the target */
line(getmaxx() - 70, y + 15, getmaxx() - 70, y + 80);

/* hand and legs target */
line(getmaxx() - 70, y + 20, getmaxx() - 50, y + 60);
line(getmaxx() - 70, y + 20, getmaxx() - 90, y + 60);

line(getmaxx() - 70, y + 80, getmaxx() - 90, y + 125);
line(getmaxx() - 70, y + 80, getmaxx() - 50, y + 125);

top[0] = x + 78, top[1] = y - 3;
bot[0] = x + 82, bot[1] = y;

/* motion of bullet */
for (j = top[0]; j < getmaxx() - 80; j = j + 10) {
/* draws bullet at the curren given position */
setcolor(LIGHTRED);
setfillstyle(SOLID_FILL, LIGHTRED);
rectangle(top[0], top[1], bot[0], bot[1]);
floodfill(top[0] + 1, top[1] + 1, LIGHTRED);

delay(10);

/* erase bullet at the previous position */
setcolor(BLACK);
setfillstyle(SOLID_FILL, BLACK);
rectangle(top[0], top[1], bot[0], bot[1]);
floodfill(top[0] + 1, top[1] + 1, BLACK);
top[0] = top[0] + 10;
bot[0] = bot[0] + 10;
}

/* bullet at the top of target */
setcolor(LIGHTRED);
setfillstyle(SOLID_FILL, LIGHTRED);
rectangle(top[0] - 10, top[1], bot[0] - 10, bot[1]);
floodfill(top[0] - 9, top[1] + 1, LIGHTRED);

sleep(1);
cleardevice();
}

getch();

/* deallocate memory allocated for graphic screen */
closegraph();
return 0;
}


Tuesday, 2 July 2019

how to make pie chart||lead to tech||luv yadav

#include <stdio.h>
#include <conio.h>
#include <graphics.h>
#include <dos.h>

int main() {
char str[64];
/* request auto detection */
int gdriver = DETECT, gmode, err;
int i, midx, midy, tmp1, tmp2;
int v[4][2], w[4][2], x[4][2], y[4][2], z[4][2];
char depart[5][32] = {"virat kohli", "dhoni",
"pandya", "sikhar",
"shami"};

/* initialize graphic mode */
initgraph(&gdriver, &gmode, "C:/TURBOC3/BGI");
err = graphresult();

if (err != grOk) {
/* error occurred */
printf("Graphics Error: %s",
grapherrormsg(err));
return 0;
}

/* mid position in x and y axis */
midx = getmaxx() / 2;
midy = getmaxy() / 2;

/* line at y and x-axis */
line(70, 0, 70, getmaxy() - 50);
line(70, getmaxy() - 50, getmaxx(), getmaxy() - 50);

/* units at y-axis */
for (i = 0; i < 5; i++) {
sprintf(str, "%d", 25 * i);
settextstyle(TRIPLEX_FONT, HORIZ_DIR, 1);
settextjustify(CENTER_TEXT, CENTER_TEXT);
moveto(40, getmaxy() - 70 - i * 80);
outtext(str);
}

/* y-axis represents revenue */
moveto(10, midy);
settextstyle(TRIPLEX_FONT, VERT_DIR, 3);
sprintf(str, "%s", "VALUE");
outtext(str);

/* x-axis represent departments */
moveto(midx, getmaxy() - 10);
settextstyle(TRIPLEX_FONT, HORIZ_DIR, 1);
sprintf(str, "%s", "PLAYERS");
outtext(str);

tmp1 = getmaxy() - 40;
tmp2 = 135;

/* place the departments in x-axis */
for (i = 0; i < 5; i++) {
moveto(tmp2, tmp1);
outtext(depart[i]);
tmp2 = tmp2 + 110;
}

/* set the initial points of vertical bars */
v[0][0] = 95, v[0][1] = getmaxy() - 51;
v[1][0] = 175, v[1][1] = getmaxy() - 51;

w[0][0] = 205, w[0][1] = getmaxy() - 51;
w[1][0] = 285, w[1][1] = getmaxy() - 51;

x[0][0] = 315, x[0][1] = getmaxy() - 51;
x[1][0] = 395, x[1][1] = getmaxy() - 51;

y[0][0] = 425, y[0][1] = getmaxy() - 51;
y[1][0] = 505, y[1][1] = getmaxy() - 51;

z[0][0] = 535, z[0][1] = getmaxy() - 51;
z[1][0] = 615, z[1][1] = getmaxy() - 51;

/* animate vertical bar graphs */
for (i = 0; i < getmaxy() - 100; i++) {
/* vertical bar 1 – electronics */
if (i <= getmaxx() - 310) {
setcolor(BLUE);
line(v[0][0], v[0][1], v[1][0], v[1][1]);
v[0][1] = v[0][1] - 1;
v[1][1] = v[1][1] - 1;
}

/* vertical bar 2 – medical */
if (i <= getmaxx() - 340) {
setcolor(LIGHTRED);
line(w[0][0], w[0][1], w[1][0], w[1][1]);
w[0][1] = w[0][1] - 1;
w[1][1] = w[1][1] - 1;
}

/* vertical bar 3 – music */
if (i <= getmaxx() - 380) {
setcolor(LIGHTGREEN);
line(x[0][0], x[0][1], x[1][0], x[1][1]);
x[0][1] = x[0][1] - 1;
x[1][1] = x[1][1] - 1;
}

/* vertical bar 4 – clothing */
if (i <= getmaxx() - 450) {
setcolor(DARKGRAY);
line(y[0][0], y[0][1], y[1][0], y[1][1]);
y[0][1] = y[0][1] - 1;
y[1][1] = y[1][1] - 1;
}

/* vertical bar 5 – services */
if (i <= getmaxx() - 550) {
setcolor(YELLOW);
line(z[0][0], z[0][1], z[1][0], z[1][1]);
z[0][1] = z[0][1] - 1;
z[1][1] = z[1][1] - 1;
}

/* sleep for 25 milliseconds */
delay(25);
}

getch();

/* deallocate memory allocated for graphic screen */
closegraph();

return 0;
}



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, 8 September 2018

program for simple calculator in c++

#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<process.h>
int main()
 {
 clrscr();
 char ch,ch1;
 float a,b,add,sub,multi,div;
 cout<<"\nsimple calculator:";
 cout<<"\n1.Addition";
 cout<<"\n2.Subtraction";
 cout<<"\n3.Multiplication";
 cout<<"\n4.Division";
 cout<<"\n5.Exit"<<"\n";
 cout<<"Enter your choice:";
 do
 {
 cin>>ch;
 if(ch=='1'|| ch=='2'|| ch=='3'|| ch=='4')
 {
 cout<<"Enter the value of a:";
 cin>>a;
 cout<<"Enter the value of b:";
 cin>>b;
 }
 switch(ch)
 {
 case'1':add=a+b;
       cout<<"Addition="<<add;
       break;
 case'2':sub=a-b;
       cout<<"Subtraction="<<sub;
       break;
 case'3':multi=a*b;
       cout<<"Multiplication="<<multi;
       break;
 case'4':if(b==0)
  cout<<"Divide by Zero error!!!";
  else
  div=b/a;
       cout<<"Division="<<div;
       break;
 case'5':cout<<"breaking:";
 exit(0);
 default:cout<<"Wrong choice!!!";
cout<<"Enter a valid one";
break;
 }

cout<<"\nWant to enter more (y/n)?";
cin>>ch1;
if(ch1=='y'|| ch1=='y')
cout<<"again enter your choice (1-5):";
}
while(ch1=='y'|| ch1=='y');
getch();
return(0);
}





Wednesday, 5 September 2018

program for row matrix in c++

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



program for column matrix in c++

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



Wednesday, 20 June 2018

program to find (a+b)2+(a-b)2 in c++

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

for video click on link given below

https://www.youtube.com/watch?v=ykTaoik98yo

Sunday, 17 June 2018

program to find (a+b)2 in c++

#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);
}



https://www.youtube.com/watch?v=ykTaoik98yo

program to find the area of triangle in c++

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



https://www.youtube.com/watch?v=ykTaoik98yo

program to find the area of square in c++

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


https://www.youtube.com/watch?v=ykTaoik98yo

program to find area of rectangle in c++


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



program for divide in c++

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


program of multiplication in c++

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


program of subtraction in c++

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

program for subtraction in c

#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a, b , sub;
printf("enter the value a:");
scanf("%d",&a);
printf("enter the value b:");
scanf("%d",&b);
(sub=a-b);
printf("the sub of given number is:");
printf("%d",sub);
getch();
return(0);
}

sum program in c++

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


hello world program in c++

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<"hello world";
getch();
}