Write a program to implement the motion of a bouncing ball
using a downward gravitational force and a ground-plane
friction force. Initially the ball is to be projected in to
space with a given velocity vector

Answers were Sorted based on User's Feedback



Write a program to implement the motion of a bouncing ball using a downward gravitational force an..

Answer / tsigereda

#include<dos.h>
#include<iostream.h>
#include<graphics.h>
#include<math.h>
#include<conio.h>
void *ball;
void image()
{
//ball
//setcolor(RED);
setfillstyle(SOLID_FILL,RED);
fillellipse(10,10,10,10);
//ball=malloc(imagesize(0,0,50,50));
//getimage(0,0,50,50,ball);
cleardevice();
}
void main()
{

int d=DETECT,m;
initgraph(&d,&m,"C:\\tc\\bgi");
float x=1,y=0.00000,j=.5,count=.1;
float r=15;
int l=getmaxx()/2,t=0;

image();
setbkcolor(GREEN);

setcolor(30);
line(0,450,650,450);
sleep(1);
for(int k=0;k<=7;k++)
{

for(float i=90;i<270;i+=10)
{
y=cos(((i*22/7)/180))/j;

if(y>0)
y=-y;
x+=5;

setcolor(14);
setfillstyle(1,14);
circle(x,y*200+400,r);
floodfill(x,y*200+400,14);


delay(100);

setcolor(0);
setfillstyle(1,0);
circle(x,y*200+400,r);
floodfill(x,y*200+400,0);

}

j+=count;
count+=.1;
}
getch();
}

Is This Answer Correct ?    11 Yes 3 No

Write a program to implement the motion of a bouncing ball using a downward gravitational force an..

Answer / tsigereda

which is animate downward gravitational force.

Is This Answer Correct ?    6 Yes 1 No

Post New Answer

More C Code Interview Questions

main() { int i =0;j=0; if(i && j++) printf("%d..%d",i++,j); printf("%d..%d,i,j); }

1 Answers  


why java is platform independent?

13 Answers   Wipro,


char inputString[100] = {0}; To get string input from the keyboard which one of the following is better? 1) gets(inputString) 2) fgets(inputString, sizeof(inputString), fp)

1 Answers  


Find your day from your DOB?

15 Answers   Accenture, Microsoft,


Write a program to receive an integer and find its octal equivalent?

7 Answers  






What are segment and offset addresses?

2 Answers   Infosys,


main() { signed int bit=512, i=5; for(;i;i--) { printf("%d\n", bit >> (i - (i -1))); } } a. 512, 256, 0, 0, 0 b. 256, 256, 0, 0, 0 c. 512, 512, 512, 512, 512 d. 256, 256, 256, 256, 256

2 Answers   HCL,


#include<stdio.h> main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }

1 Answers  


C program to print magic square of order n where n > 3 and n is odd

2 Answers   Accenture,


main() { int y; scanf("%d",&y); // input given is 2000 if( (y%4==0 && y%100 != 0) || y%100 == 0 ) printf("%d is a leap year"); else printf("%d is not a leap year"); }

1 Answers  


#include<stdio.h> main() { char s[]={'a','b','c','\n','c','\0'}; char *p,*str,*str1; p=&s[3]; str=p; str1=s; printf("%d",++*p + ++*str1-32); }

2 Answers   CNSI,


void main () { int x = 10; printf ("x = %d, y = %d", x,--x++); } a. 10, 10 b. 10, 9 c. 10, 11 d. none of the above

2 Answers   HCL,


Categories