This was my last project for my first computer programming class, which I turned in today! I like computer science! I learned how to js inject this morning! I deleted the White House!!!!!!!!!!!!!!!!!
Terminal Velocity of a Cow
Code:
#include<stdio.h>
#include<math.h>
main(){
float tV,m,g=9.81,cD=0.1,p=1.2754,a,maths;
printf("How fat is your cow in kilograms?\n");
scanf("%f",&m);
printf("How many cubic kilometers does your cow take up?\n");
scanf("%f",&a);
maths=((2*m)*g)/((p*a)*cD);
tV=sqrt(maths);
printf("At IUPAC standard temperature and pressure and assuming your cow is a\n smooth sphere, the terminal velocity of your cow is: %.2f meters per second.",tV);
system("pause");
}
Palindrome ++
Code:
#include<stdio.h>
#include<string.h>
int max=50;
int getStringF(char[],int,FILE *);
main()
{
FILE *oF,*iF;
oF=fopen("output.txt","w");
iF=fopen("data6.txt","r");
fprintf(oF,"Palindrome program Fall 2011 \n");
fprintf(oF,"Project #6 Due 12/9/11 rundate\n\n");
fprintf(oF,"Palindrome? Input string Name: Good Ole Rick. He's a cowboy.\n");
char string[max];
int e;
e=getStringF(string,max,iF);
while(e!=-1)
{
char string2[max];
int i=0,j=0;
for(i=strlen(string)-1;i>=0;i--)
{
string2[j]=string[i];
j++;
}
string2[j]='\0';
if((strcmp(string,string2))==0)
fprintf(oF," YES %s*\n",string);
else
fprintf(oF," NO %s*\n",string);
e=getStringF(string,max,iF);
}
fprintf(oF,"\n\n\nEnd of program, Normal Termination");
fclose(iF);
fclose(oF);
}
int getStringF(char string[],int max,FILE *iF)
{
char c;
int p=0;
c=getc(iF);
while((c!= EOF)&&(c!='\n')&&(p<max))
{
string[p]=c;
p++;
c=getc(iF);
}
string[p]='\0';
if(c==EOF)
p=-1;
return p;
}