YOUNGBLOOD

LET'S ROCK THE WORLD  

login ]
HOME | ENTERTAINMENT | C-PROGRAM | COLLECTION OF WEBSITES | ADMINISTRATOR | ATT 1-20 | html testing | nature     

Download the original attachment

Program code:

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,c,d,e,f,g;

clrscr();

printf(“\nEnter the 2 values:”);

scanf(“%d %d “,&a,&b);

c=a+b;

d=a-b;

e= a*b;

f=a/b;

g=a%b;

printf(“\nThe sum is %d”,c);

printf(“\nThe difference is %d”, d);

printf(“\nThe product is %d”,e);

printf(“\nThe divided result is %d”,f);

printf(“\nThe modulus is %d”,g);

getch();

}






OUT PUT:

Enter the 2 values: 3 3

The sum is 6

The difference is 0

The product is 9

The divided result is 1

The modulus is 0





PROGRAM CODE:

#include<stdio.h>

#include<conio.h>

#define PI 3.14

void main()

{

float r, area;

clrscr();

printf(“\nEnter the radius: ”);

scanf(‘%f”,&r);

area=PI*r*r;

printf(“\nThe area of circle is %f”,area);

getch();

}















OUT PUT :

Enter the radius: 2

The area of a circle is 12.56


PROGRAM CODE:

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,c;

clrscr();

printf(“\nEnter the values for a,b,c:);

scanf(“%d %d %d”,&a,&b,&c);

if (a>b&&a>c)

printf(“ \nThe biggest number is %d”,a);

else if(b>c)

printf(“\nThe biggest number is %d”,b);

else

printf(“\nThe biggest number is %d”,c);

getch();

}













OUTPUT:

Enter the values for a,b,c:2 9 6

The biggest number is 9




PROGRAM CODE:

#include<stdio.h>

#include<conio.h>

void main()

{

float f,c;

clrscr();

printf(“\nEnter the temperature in farenheit: ”);

scanf(“ %f”,&f);

c=(f-32)/1.8;

printf(“\nTemperature in Celsius is %f”,c);

getch();

}

















OUTPUT:

Enter the temperature in farenheit: 212

Temperature in Celsius is 100.000000


PROGRAM CODE:

#include<stdio.h>

#include<conio.h>

#include<math.h>

void main()

{

float a,b,c,s,area;

clrscr();

printf(“\nEnter the values for a,b,c:”);

scanf(“%f%f%f”,&a,&b,&c);

s=(a+b+c)/2;

area=sqrt(s*(s-a)*(s-b)*(s-c);

printf(“\nThe area of triangle is %f ”,area);

getch();

}













OUT PUT:

Enter the values for a,b,c:10 10 10

The area of triangle is 43.301270



PROGRAM CODE:

#include<stdio.h>

#include,conio.h>

void main()

{

int x=-1;y=1,z,i,n;

clrscr();

printf(“\nEnter the n values:”);

scanf(‘%d”,&n);

printf(“%d”,&n)

printf(“\nThe fibbonacci series:”)

for(i=0;i<n;i++)

{

z=x+y;

x=y;

y=z;

printf(“\n%d”,z);

}

getch();

}

OUTPUT:

Enter the n values:10

The fibbonacci series:

0

1

1

2

3

5

8

13

21

34





PROGRAM CODE:

#include<stdio.h>

#include<conio.h>

void main()

{

long int fact=1,n,i;

clrscr();

printf(“\nEnter the number: ”);

scanf(“%d”,&n);

for(i=1;i<=n;i++)

{

fact*=i;

}

printf(“\nThe factorial of the number is %d”,fact);

getch();

}














OUT PUT:

Enter the number: 5

The factorial of the number is 120


PROGRAM CODE:

#include<stdio.h>

#include<conio.h>

void main()

{

int r,n,n1,sum=0;

clrscr();

printf(“\nEnter the number:”);

scanf(“%d’,&n);

n1=n;

while(n>0)

{

r=n%10;

n=n/10;

sum=(r*r*r)+sum;

}

if(sum==n1)

{

printf(“\nThe number %d is armstrong”);

}

else

{

printf(“\nThe number %d is not armstrong”);

}

getch();

}





OUT PUT:

Enter the number:153

The number 153 is armstrong

PROGRAM CODE:

#include<stdio.h>

#include<conio.h>

void main()

{

int a[10][10],n,i,j,s;

clrscr();

printf(“\nEnter the no of rows:”);.

scanf(“%d”,&n);

for(i=0;i<n;i++)

{

for(s=n;s>i;s--)

printf(“ “);

a[i][j]=1;

printf(“%d”,a]i][j]);

if(i>0)

{

for(j=1;j<i;j++)

a[i][j]=a[i-1][j-1]+a[i-1][j];

}

a[i][j]=1;

printf(‘%d”,a[i][j]);

}

printf(‘\n”);

getch();

}











OUT PUT:

Enter the no of rows:4

1

      1. 1

1 2 1

1 3 3 1



































PROGRAM CODE:

#include<stdio.h>

#include<conio.h>

void main()

{

int a[5][5],b[5][5],c[5][5],i,j,m,n,p,q,k;

clrscr();

printf(“\nEnter the order of I matrix:”);

scanf(‘%d %d”,&m,&n);

printf(“\nEnter the order of II matrix:”);

scanf(‘%d %d “,&p,&q);

if(n==p)

{

printf(“\nEnter the values of I matrix:”);

for(i=0;i<m;i++)

for(j=0;j<n;j++)

scanf(“%d”,&a[i][j]);

printf(“\nEnter the values of II matrix:”);

for(i=0;i<p;i++)

for(j=0;j<q;j++)

scanf(‘%d”,&b[i][j]);

printf(“\nMatrix multiplication axb:\n”);

for(i=0;i<m;i++)

{

for(j=0;j<q;j++)

{

c[i][i]=0;

for(k=0;k<p;k++)

c[i][i]=c[i][j]+a[i][k]*b[k][i];

}









else

{

printf(“Matrix multiplication is invalid “);

printf(“\nMatrix multiplication axb:\n”);

}

for(i=0;i<m;i++)

for(j=0;j<q;j++)

printf(“%d\t’,c[i][i]);

}

printf(“\n”);

}

getch();

}











OUT PUT:

Enter the order of I matrix:2 2

Enter the order of II matrix:2 2

Enter the value of I matrix:2 2 2 2

Enter the value of II matrix:2 2 2 2

Matrix multiplication axb:

  1. 8

8 8




PROGRAM CODE:

#include<stdio.h>

#include<conio.h>

void main()

{

int pid[10],quantity[10],rate[10],price[10],i,n;

char pname[10];

clrscr();

printf(“\nEnter the number of items:”);

scanf(“%d”,&n);

for(i=1;i<=n;i++)

{

printf(“\n\nEnter the product id:”);

scanf(“%s”,&pid[i]);

printf(“\nEnter the product name:”);

scanf(“%s”,&pname[i]);

printf(“Enter the rate of product:”);

scanf(“%d”,&rate[i]);

printf(“\nEnter the quantity:”);

scanf(“%d”,&quantity[i]);

}

clrscr();

printf(“\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSALES REPORT”);

printf(“\n\t\t*---------------------*------------------*-------------------*”);

printf(“\n\t\t\t\pid\t\t\t\tproductname\t\t\t\trate\t\t\t\tquantity\t\t\t\tprice”);

for(i=1;i<=n;i++)

{

price[i]=rate[i]*quantity[i]);

printf(“\n\t\t\t%d\t\t\t\t\t\t\t\t\t\t\t %s\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t%d\t\t\t

\t\t\t\t%d\t\t\t\t\t\t\t\t%d”,pid[i],&pname[i]rate[i],quantity[i],price[i]”);

}

getch();

}






OUT PUT:

Enter the number of items:2

Enter the product id:001

Enter the product name:shirt

Enter the rate of product:350

Enter the quantity:3

Enter the product id:002

Enter the product name:pant

Enter the rate of product:500

Enter the quantity:3

OUTPUT IN CONSOLE SCREEN:

SALES REPORT

*---------------------*------------------*-------------------*

pid productname rate quantity price

001 shirt 350 3 1050

002 pant 500 3 1500




















PROGRAM CODE:

#include<stdio.h>

#include<conio.h>

void main()

{

int i,n;

float x,sum,t;

clrscr();

printf(“\nEnter the values of x,n:”);

scanf(“%f%d”,&x,&n);

x=(x*3.14)/180;

t=x;

sum=t;

for(i=1;i<=n;i++)

{

t=(t*(-1)*x*x)/(2*i((2*i)+1));

sum=sum+t;

}

printf(“\nValue of sine series is %f”,sum);

getch();

}







OUT PUT:

Enter the values of x,n:45 1

Value of sine series is 0.704377



PROGRAM CODE:

#include<stdio.h>

#include<conio.h>

void main()

{

int i,n;

float x,sum,t;

clrscr();

printf(“\nEnter the values of x,n:”);

scanf(“%f%d”,&x,&n);

x=(x*3.14)/180;

t=1;

sum=t;

for(i=1;i<=n;i++)

{

t=(t*(-1)*x*x)/(2*i((2*i)-1));

sum=sum+t;

}

printf(“\nValue of Cosine series is %f”,sum);

getch();

}










OUT PUT:

Enter the values of x,n:34 1

Value of Cosine series is 0.824110



PROGRAM CODE:

#include<stdio.h>

#include<conio.h>

void main()

{

char s1[20],s2[20],s3[20];

int x,l1,l2,l3,f;

clrscr();

printf(“\nEnter the two string constants :\n”);

scanf(“%s%s”,s1,s2);

x=strcmp(s1,s2);

if(x!=0)

{

printf(“\n The string are not equal:”);

strcat(s1,s2);

}

else

printf(“\nThe strings are equal”);

strcpy(s3,s1);

l1=strlen(s1);

l2=strlen(S2);

l3=strlen(s3);

printf(“\ns1=%s\tlength=%d\n”,s1,l1);

printf(“\ns2=s2\t length=%d\n”,s2,l2);

printf(“\ns3=%s\t length=%d\n”,s3,l3);

f=strrev(s1,s2);

printf(“\nThe reversed string is %s”,f);

getch();

}









OUT PUT:

Enter the two string constants:

siva

siva

The strings are equal

s1=siva length=4

s2=siva length=4

s3=siva length=4

The reversed string is avis





















PROGRAM CODE:

#include<stdio.h>

#include<conio.h>

void main()

{

int i,m;

float deviation,variance,list[20];

float sd(),va();

clrscr();

printf(“Standard deviation\n”);

printf(“Enter the upper limit:”);

scanf(“%d”,&n);

printf(“Enter the %d elements:\n”,n);

for(i=0;i<n;i++)

scanf(“%f”,&list[i]);

for(i=0;i<m;i++)

printf(“%6.2f”,list[i]);

deviation=3d(list,n);

variance=va(list,n);

printf(“variance is %6.5f \n”,variance);

printf(“standard deviation is %6.5f:\n”,deviation);

getch();

}

float sd(x,m);

float x[20];

int m;

{

int i;

float mean,div,sum=0.0;

float avg();

mean=avg(x,m);

printf(“\nMean of %2d elements is %5.2f\n”,mean);

for(i=1;i<=m;i++)

sum=sum+(mean-x[i])*(mean-x[i]);

div=sqrt+(sum/m);

return(div);

}

float va(x,m);

float x[20];

int m;

{

int i;

float mean,var,sum=0.0;

float avg();

mean=avg(x,m);

for(i=0;i<=m;i++)

sum=sum+(mean-x[i])*(mean-x[i]);

var=sum/m;

return(var);

}

float avg(a,n)

float a[20]

{

int i;

float sum=0.0;

for(i=0;i<=n;i++)

sum+=a[i];

return(sum/n);

}

OUTPUT:

Standard deviation

Enter the upper limit:4

Enter the 4 elements:

1

3

4

5

Mean of 4 elements is 3.250000

Variance is 0.765620

standard deviation is -32766.0

PROGRAMCODE:

#include<stdio.h>

#include<conio.h>

int q=0

void main()

{

int seq(int[],int,int);

int i,n,x,b,q,z;

int a[10];

clrscr();

printf(“\nEnter the number of terms:”);

scanf(“%d”,&n);

printf(“\nEnter the number”);

for(i=1;i<=n;i++)

{

scanf(“%d”,&a[i]);

}

printf(“\nEnter the number to be found:”);

scanf(“%d”,&x);

b=seq(a,x,n);

if(b==q)

printf(“\n the number is found at position %d”,q);

else

printf(“\n the number is not found”)

getch();

}

int seq(int x[],int y,int z)

{

for(q=1;q<=z;q++)

{

if(x[q]==y)

{

return(q);

}

}

getch();

}




OUT PUT:

Enter the number of items 5

Enter the numbers 1 3 5 7 9

Enter the number to be found 5

The number is found at 3rd position


























PROGRAM CODE:

#include<stdio.h>

#include<conio.h>

struct stud

{

int roll_ no,m1,m2,m3,total;

char name[20];

float avg;

}s[10];

void main()

{

int i,n;

clrscr();

printf(“\nstudents marksheet \n”);

printf(“\nEnter the number of students:”);

scanf(“%d”,&n);

printf(“\n Enter the roll no ,name and 3 subject marks:”);

for(i=1;i<=n;i++)

{

scanf(“%d%s%d%d%d”,&s[i].roll_no,&s[i].name,

&s[i].m1,&s[i].m2,&s[i].m3);

s[i].total=(s[i].m1+s[i].m2+s[i].m3);

s[i].avg=s[i]/3;

}

printf(“\n students marksheet ”);

printf(“\n\ROLLNO\tNAME\tMARK1\tMARK2\tMARK3\tTOTAL

\tAVERAGE\n”);

for(i=1;i<=n;i++)

{

printf(“%d\t%s\t%d\t%d\t%d\t%2f\n”,s[i].roll_no,

s[i].name,s[i].m1,s[i].m2,s[i].m3,s[i].total,s[i].avg);

}

getch();

}

OUTPUT

students marksheet

Enter the number of students:2

Enter the roll no ,name and 3 subject marks:

1 Abdul 99 95 95

Enter the datas

2 Arun 95 90 90

students marksheet

ROLLNO NAME M1 M2 M3 TOTAL AVERAGE

1 Abdul 99 95 95 289 96.000000

2 Arun 95 90 90 275 91.000000




















PROGRAM CODE:

#include<stdio.h>

#include<conio.h>

void main()

{

char name[20];

int roll_no,m1[10],m2[10],m3[10],total[10],avg[10],n,i;

clrscr();

FILE *f1,*f2;

f1=fopen(“input.txt”,”w”);

printf(“\nEnter the number of students:”);

scanf(“%d”,&n);

for(i=0;i<=n;i++)

{

printf(“\nName:”);

scanf(“%s”,name[i]);

printf(“\nRoll no:”);

scanf(“%d”,&roll_no[i]);

printf(“\nMark1:”);

scanf(“%d”,&m1[i]);

printf(“\nMark2:);

scanf(“%d”,&m2[i]);

printf(“\nMark3:”);

scanf(“%d”,&m3[i]);

}

for(i=0;i<=n;i++)

{

fprintf(f1,”\nName:%s”,name[i]);

fprintf(f1,”\nRoll no:%d”,roll_no[i]);

fprintf(f1,”\nm1:%d\nm2:%d\nm3:%d”,m1[i],m2[i],m3[i]);

fclose(f1);

f1=fopen(input.txt”,”r”);

f2=fopen(“Output.txt”,”w”);


for(i=0;i<.=n;i++)


{

fscanf(f1,”%d”,&m1[i]);

fscanf(f2,”%d”,&m2[i]);

fscanf(f3,”%d”,&m3[i]);

total=m1+m2[i]+m3[i];

avg=total/3;

printf(“\n Roll no\tName\ttotal\taverage\n”);

for(i=0;i<=n;i++)

{

printf(“%d\t\t\t\t\t\t\t\t%s\t\t\t\t\t%d\t\t\t\t\t%d\t\t\t\t\t%d\n”

,roll_no[i],name[i],total[i],avg);

}

fprintf(f2,”\nRoll no\t Name\tTotal\taverage\n”);

for(i=0;i<=n;i++)

fprintf(f2,”%d\t\t\t\t\\t\t%s\t\t\t\t\t\t%d\t\t\t\t\t%d”,

roll_no[i],name[i],total[i],avg[i]);

fclose(f1);

fclose(f2);

getch();

}

OUT PUT:

Enter the number of students:2

INPUT.TXT:

Name:Ashok

Roll no:1

Mark1:90

Mark2:80

Mark3:80

Enter the name:Bala

Roll no:2

Mark1:80

Mark2:80

Mark3:90

OUTPUT.TXT:

Rollno Name Total average

1 Ashok 250 85

2 Bala 250 85



































PROGRAM CODE:

#include<stdio.h>

#include<conio.h>

void main()

{

char ch;

FILE *f1,*f2,*f3;

f1=fopen(“input1.txt”,”r”);

f2=fopen(“input2.txt”,”r”);

f3=fopen(“output.txt”,”w”);

printf(“\n First file data:”);

while(!feof(f1))

{

ch=fgetc(f1);

printf(“%c”,ch);

fputc(ch,f3);

}

printf(“\n Second file data:”);

while(!feof(f2)

{

ch=fgetc(f2);

printf(“%c”,ch);

fputc(ch,f3);

}

printf(“\n The two files merged successfully”);

fclose(f1);

fclose(f2);

fclose(f3);

getch();

}




OUT PUT:

INPUT1.TXT:

Sachin

INPUT2.TXT:

Tendulkar

OUTPUT IN CONSOLE SCREEN:

First file data: Sachin

Second file data: Tendulkar

Output file data:Sachin Tendulkar




































PROGRAM CODE:

#include<stdio.h>

#include<conio.h>

void main()

{

char str[20],temp[50];

int i=0,j=0,n;

clrscr();

printf(“\nEnter the number of persons:”);

scanf(“%d”,&n);

printf(“\nEnter the name of persons: ”);

for(i=0;i<n;i++)

{

scanf(“\n%s”,str[i]);

}

printf(“\nThe names in alphabetical order:”);

for(i=1;i<n;i++)

{

if(strcmp(str[j-1],str[j]>0));

{

strcpy(temp,str[j-1]);

strcpy(str[j-1],str[j]);

strcpy(str[j],temp);

}

}

}



for(i=0;i<n;i++)

{

printf(“\n%s”,str[i]);

}

getch();

}



OUT PUT:

Enter the number of persons:4

Enter the name of persons:

Siva

Raja

Vel

Arun

The names in alphabetical order:

Arun

Raja

Siva

Vel