Created
November 7, 2019 11:28
-
-
Save tapanis517/8ef2eb71a7f689637e4411ce69d4b2b0 to your computer and use it in GitHub Desktop.
assingnment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assignment no.1 | |
1. | |
#include<stdio.h> | |
void main() | |
{ | |
int a,b; | |
printf("Enter sides of rectangle="); | |
scanf("%d %d",&a,&b); | |
printf("Area of rectangle=%d",a*b); | |
} | |
2. | |
#include<stdio.h> | |
void main() | |
{ | |
int a,b,c,d; | |
printf("Enter any two number="); | |
scanf("%d %d",&a,&b); | |
c=a*a; | |
d=b*b*b; | |
printf("Output=%d",c+d); | |
3. | |
#include<stdio.h> | |
void main() | |
{ | |
int a,b,c,p,m; | |
printf("Enter any four number="); | |
scanf("%d %d %d %d",&a,&b,&c,&p); | |
m=a*(p*p)+b*p+c; | |
printf("%d",m); | |
} | |
4. | |
#include<stdio.h> | |
void main() | |
{ | |
int a; | |
printf("Enter any number="); | |
scanf("%d",&a); | |
int m; | |
m=a/10; | |
printf("%d",m); | |
} | |
5. | |
#include<stdio.h> | |
void main() | |
{ | |
int a; | |
printf("Enter any number="); | |
scanf("%d",&a); | |
int m; | |
m=a/100; | |
printf("Output=%d",m); | |
} | |
6. | |
#include<stdio.h> | |
void main() | |
{ | |
int a; | |
printf("Enter any number="); | |
scanf("%d",&a); | |
int b,c; | |
b=a/10; | |
c=b%10; | |
printf("Output=%d",c); | |
} | |
7. | |
#include<stdio.h> | |
void main() | |
{ | |
int a; | |
printf("Enter any number="); | |
scanf("%d",&a); | |
int b,c; | |
b=a%100; | |
c=b%10; | |
b=b/10; | |
printf("%d",b+c); | |
} | |
8. | |
#include<stdio.h> | |
void main() | |
{ | |
int a; | |
printf("Enter any number="); | |
scanf("%d",&a); | |
int p=a%10; | |
a=a/10; | |
int m=a*10+p*2; | |
printf("%d",m); | |
} | |
10. | |
#include<stdio.h> | |
void main() | |
{ | |
int a; | |
printf("Enter any number="); | |
scanf("%d",&a); | |
int m,n,p; | |
m=a%10; | |
a=a/10; | |
n=a%10; | |
a=a/10; | |
p=a*100+m*10+n; | |
printf("%d",p); | |
} | |
assignment no.2 | |
1. | |
#include<stdio.h> | |
#include<math.h> | |
void main() | |
{ | |
int a,b,c; | |
printf("Enter Sides Of The Tringle="); | |
scanf("%d %d %d",&a,&b,&c); | |
float s; | |
float A; | |
s=(a+b+c)/2; | |
A=s*(s-a)*(s-b)*(s-c); | |
float p; | |
p=sqrt(A); | |
printf("%f",p); | |
} | |
2. | |
#include<stdio.h> | |
#include<math.h> | |
void main() | |
{ | |
int a,b,c,d; | |
printf("Enter co-ordinate="); | |
scanf("%d %d %d %d",&a,&b,&c,&d); | |
int m,n,p; | |
float t; | |
m=(c-a)*(c-a); | |
n=(d-b)*(d-b); | |
p=m+n; | |
t=sqrt(p); | |
printf("%.3f",t); | |
} | |
3. | |
#include<stdio.h> | |
void main() | |
{ | |
int a,b,c,d,e,f; | |
printf("Enter all three cordinates of Tringle"); | |
scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f); | |
float A; | |
A=0.5*(a*(d-f)+c*(f-b)+e*(b-d)); | |
printf("%f",A); | |
} | |
4. | |
#include<stdio.h> | |
void main() | |
{ | |
float a,b,c; | |
printf("enter any number="); | |
scanf("%f %f %f",&a,&b,&c); | |
printf("Equation=%.0fx+%.0fy=%.0f",a,b,c); | |
float m; | |
m=(-a)/b; | |
printf("\n%f",m); | |
} | |
5. | |
#include<stdio.h> | |
#include<math.h> | |
int main() | |
{ | |
int a,b,c,d,e; | |
float f; | |
printf("enter the co-ordinates a,b\t\n"); | |
scanf("%d,%d",&a,&b); | |
printf("enter co-efficients of line equation c,d,e\t\n"); | |
scanf("%d,%d,%d",&c,&d,&e); | |
f=(a*c+b*d+e)/sqrt(c*c+d*d); | |
printf("distance of point from line is%f",f); | |
} | |
6. | |
#include<stdio.h> | |
#include<math.h> | |
int main() | |
{ | |
int a,b,c; | |
float r,p,q; | |
printf("enter the values of a,b,c\n"); | |
scanf("%d,%d,%d",&a,&b,&c); | |
p=(-a)/2; | |
q=(-b)/2; | |
r=sqrt(p*p+q*q-c); | |
printf("center of the circle is %f,%f\n",p,q); | |
printf("radius of the circle is %f",r); | |
} | |
7. | |
#include<stdio.h> | |
#include<math.h> | |
int main() | |
{ | |
int a,b,c,p,q,r; | |
float x,y; | |
printf("enter the value of a,b,c\n"); | |
scanf("%d,%d,%d",&a,&b,&c); | |
printf("enter the value of p,q,r\n"); | |
scanf("%d,%d,%d",&p,&q,&r); | |
y=(p*c-a*r)/(a*q-p*b); | |
x=-(b*y+c)/a; | |
printf("point of intersection is %f,%f",x,y); | |
} | |
8. | |
#include<stdio.h> | |
#include<math.h> | |
int main() | |
{ | |
int a,b,c; | |
float A; | |
printf("enter the values of a,b,c"); | |
scanf("%d,%d,%d",&a,&b,&c); | |
A=acos(b*b+c*c-a*a)/2*b*c; | |
printf("value of angle A%f",A); | |
} | |
9. | |
#include<stdio.h> | |
#include<math.h> | |
int main() | |
{ | |
float a,b,c,d,e,f,g,h; | |
float x,y,z,k,r,p,u; | |
printf("enter the values of\ta,b,c,d,e,f,g,h\n"); | |
scanf("%f,%f,%f,%f,%f,%f,%f,%f",&a,&b,&c,&d,&e,&f,&g,&h); | |
x=(-e)/2; | |
y=(-f)/2; | |
z=(-g)/2; | |
k=(a*x+b*y+c*z+d)/sqrt(a*a+b*b+c*c); | |
r=sqrt(x*x+y*y+z*z-h); | |
p=sqrt(r*r-k*k); | |
u=(3.14)*(p*p); | |
printf("area of the circle is %f",u); | |
} | |
10. | |
#include<stdio.h> | |
#include<math.h> | |
int main() | |
{ | |
float h,k,r,s,d,u; | |
printf("enter the values of h,k,r,s"); | |
scanf("%f,%f,%f,%f",&h,&k,&r,&s); | |
d=(h-s); | |
u=sqrt(r*r-d*d); | |
printf("length of chord is %f",2*u); | |
} | |
assignment no.3 | |
1. | |
#include<stdio.h> | |
void main() | |
{ | |
int a,b,c; | |
printf("enter the three numbers\n"); | |
scanf("%d,%d,%d",&a,&b,&c); | |
if(a>b) | |
{ | |
printf("greatest no. is %d",a); | |
} | |
else if(b>c) | |
{ | |
printf("greatest no. is %d",b); | |
} | |
else | |
printf("greatest no. is %d",c); | |
} | |
2. | |
#include<stdio.h> | |
int main() | |
{ | |
int a,b,c,d; | |
printf("enter any four numbers\n"); | |
scanf("%d,%d,%d,%d",&a,&b,&c,&d); | |
if(a>b) | |
{ | |
printf("greatest number is %d",a); | |
} | |
else if(b>c) | |
{ | |
printf("greatest number is %d",b); | |
} | |
else if(c>d) | |
{ | |
printf("greatest number is %d",c); | |
} | |
else | |
printf("greatest number is %d",d); | |
} | |
3. | |
#include<stdio.h> | |
void main() | |
{ | |
int a,b; | |
printf("enter any two numbers\n"); | |
scanf("%d,%d",&a,&b); | |
if(a>b) | |
{ | |
printf("%d,%d",a,b); | |
} | |
else | |
printf("%d,%d",b,a); | |
} | |
4. | |
#include<stdio.h> | |
void main() | |
{ | |
int a,b,c; | |
printf("enter the sides of triangle a,b,c"); | |
scanf("%d,%d,%d",&a,&b,&c); | |
if((a*a)==(b*b+c*c)) | |
{ | |
printf("angle A is a right angle"); | |
} | |
else | |
printf("angle A is not a right angle triangle"); | |
} | |
5. | |
#include<stdio.h> | |
void main() | |
{ | |
float a,b; | |
printf("enter the values of a,b\n"); | |
scanf("%f,%f",&a,&b); | |
if(a==0) | |
{ | |
printf("line is vertical"); | |
} | |
else | |
{ | |
float s; | |
s=(-b)/a; | |
printf("value of slope %f\n",s); | |
printf("line is not vertical"); | |
} | |
} | |
6. | |
#include<stdio.h> | |
#include<math.h> | |
void main() | |
{ | |
float a,b,c,d,k,t,p,m,n,l,r; | |
printf("enter the values of a,b,c"); | |
scanf("%f,%f,%f",&a,&b,&c); | |
k=(b*b)-4*a*c; | |
t=sqrt(k); | |
p=sqrt(-k); | |
if(k>0) | |
{ | |
m=(-b+t)/(2*a); | |
n=(-b-t)/(2*a); | |
printf("roots of equation is%f,%f",m,n); | |
} | |
else if(k==0) | |
{ | |
m=(-b+t)/(2*a); | |
printf("roots of equation is%f,%f",m,m); | |
} | |
else if(k<0) | |
{ | |
m=(-b)/(2*a); | |
l=p/(2*a); | |
r=p/(2*a); | |
printf("roots of equation are %f+%fi , %f-%fi",m,l,m,r); | |
} | |
} | |
8. | |
#include<stdio.h> | |
void main() | |
{ | |
int a,b,c; | |
printf("enter any three numbers\n"); | |
scanf("%d,%d,%d",&a,&b,&c); | |
if(a==b) | |
{ | |
printf("%d",c); | |
} | |
else if(a==c) | |
{ | |
printf("%d",b); | |
} | |
else if(b==c) | |
{ | |
printf("%d",a); | |
} | |
else | |
printf("no output"); | |
} | |
9. | |
#include<stdio.h> | |
void main() | |
{ | |
int a,b,c,d,x; | |
printf("enter the values a,b,c,d,x"); | |
scanf("%d,%d,%d,%d,%d",&a,&b,&c,&d,&x); | |
if(a==x) | |
printf("x is equal to a"); | |
else if(b==x) | |
printf("x is equal to b"); | |
else if(c==x) | |
printf("x is equal to c"); | |
else if(d==x) | |
printf("x is equal to d"); | |
else | |
printf("x is equal to none"); | |
} | |
10. | |
#include<stdio.h> | |
void main() | |
{ | |
int a,b,c,d; | |
int x; | |
printf("enter values of a,b,c,d,x\n"); | |
scanf("%d,%d,%d,%d,%d",&a,&b,&c,&d,&x); | |
if(x==a||x==b||x==c||x==d) | |
{ | |
printf("1"); | |
} | |
else if((x==a&&x==b&&x==c)||(x==a&&x==b&&x==d)||(x==b&&x==c&&x==d)) | |
{ | |
printf("3"); | |
} | |
else | |
printf("0"); | |
} | |
11. | |
#include<stdio.h> | |
#include<math.h> | |
int main() | |
{ | |
int a,b,c; | |
printf("enter any three numbers"); | |
scanf("%d,%d,%d",&a,&b,&c); | |
if((a>b&&a<c)||(a<b&&a>c)) | |
printf("%d",a); | |
else if((b>a&&b<c)||(b<a&&b>c)) | |
printf("%d",b); | |
else | |
printf("%d",c); | |
} | |
12. | |
#include<stdio.h> | |
#include<math.h> | |
int main() | |
{ | |
float a,b,c,p,q,r,d,l,u; | |
printf("enter the values of p,q,r,a,b,c"); | |
scanf("%f,%f,%f,%f,%f,%f",&p,&q,&r,&a,&b,&c); | |
d=(a*p+b*q+c)/sqrt(a*a+b*b); | |
if(d==r) | |
printf("line touches the circle"); | |
else if(d>r) | |
printf("line does not touches the circle"); | |
else if(d<r) | |
{ | |
l=sqrt(r*r-d*d); | |
u=l*d; | |
printf("line intersects the circle at two points A and B\n"); | |
printf("area of triangle is%f",u); | |
} | |
} | |
assignment no.4 | |
1. | |
#include<stdio.h> | |
int main() | |
{ | |
for(int a=20;a<=70;a+=2) | |
{ | |
printf("%d\n",a); | |
} | |
} | |
2. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int a=20;a<=40;a++) | |
{ | |
printf("%d\n",a); | |
} | |
for(int b=50;b<=80;b+=2) | |
{ | |
printf("%d\n",b); | |
} | |
} | |
3. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int a=0;a<=50;a+=2) | |
{ | |
printf("%d\n",a); | |
} | |
for(int b=51;b<=100;b+=2) | |
{ | |
printf("%d\n",b); | |
} | |
} | |
4. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int a=20;a<=40;a+=2) | |
{ | |
printf("%d\n",a); | |
} | |
for(int b=51;b<=80;b+=2) | |
{ | |
printf("%d\n",b); | |
} | |
} | |
5. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int a=1;a<=10;a++) | |
{ | |
printf("%d\n",3*a); | |
} | |
for(int b=1;b<=10;b++) | |
{ | |
printf("%d\n",7*b); | |
} | |
} | |
7. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int a=0;a<=100;a+=2) | |
{ | |
if((a%3==0)||(a%5==0)) | |
{ | |
printf("\n"); | |
} | |
else | |
{ | |
printf("%d\n",a); | |
} | |
} | |
} | |
9. | |
#include<stdio.h> | |
int main() | |
{ | |
int b; | |
for(int a=1;a<=100;a++) | |
{ | |
b=a%10; | |
if(b%3==0) | |
{ | |
printf("%d\n",a); | |
} | |
else | |
{ | |
continue; | |
} | |
} | |
} | |
10. | |
#include<stdio.h> | |
int main() | |
{ | |
for(int a=1;a<=100;a++) | |
{ | |
int b=a%10; | |
if(b>=5&&b<=8) | |
{ | |
printf("%d\n",a); | |
} | |
else | |
{ | |
continue; | |
} | |
} | |
} | |
11. | |
#include<stdio.h> | |
int main() | |
{ | |
for(int a=1;a<=100;a++) | |
{ | |
int b=a/10; | |
int c=a%10; | |
if((b+c)%7==0) | |
{ | |
printf("%d\n",a); | |
} | |
else | |
{ | |
continue; | |
} | |
} | |
} | |
12. | |
#include<stdio.h> | |
int main() | |
{ | |
for(int a=1;a<=100;a++) | |
{ | |
if((a/10)%2==1) | |
printf("%d\n",a); | |
else | |
continue; | |
} | |
} | |
13. | |
#include<stdio.h> | |
int main() | |
{ | |
for(int a=1;a<=100;a++) | |
{ | |
int b=a/10; | |
if(b%3==1) | |
printf("%d\n",a); | |
else | |
continue; | |
} | |
} | |
15. | |
#include<stdio.h> | |
void main() | |
{ | |
int p=0,m=9; | |
for(int q=1;q<=5;q++) | |
{ | |
for(int b=p;b<m;b++) | |
{ | |
if(b%2==1) | |
{ | |
printf("%d\t",b); | |
} | |
} | |
p+=20; | |
m+=20; | |
} | |
int e=11,r=19; | |
for(int w=1;w<=4;w++) | |
{ | |
for(int c=e;c<r;c++) | |
{ | |
if(c%2==0) | |
printf("%d\t",c); | |
} | |
p=p+20; | |
m=m+20; | |
} | |
} | |
assignment no.5 | |
1. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int a=1;a<=5;a++) | |
{ | |
if(a%2==1) | |
{ | |
for(int b=1;b<=20;b++) | |
{ | |
printf("*"); | |
} | |
printf("\n"); | |
} | |
else | |
{ | |
for(int c=1;c<=10;c++) | |
{ | |
printf("*O"); | |
} | |
printf("\n"); | |
} | |
} | |
} | |
2. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int a=1;a<=10;a++) | |
{ | |
for(int b=1;b<=20;b++) | |
{ | |
if((a<=3)&&(a>=8)||(a<=3)&&(b>8)||(a>=8)&&(b>=15)) | |
{ | |
printf("*"); | |
} | |
else | |
{ | |
printf("O"); | |
} | |
} | |
printf("\n"); | |
} | |
} | |
3. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int a=0;a<=3;a++) | |
{ | |
for(int b=0;b<=9;b++) | |
{ | |
if((a%2==0)&&(b%2==0)||(a%2==1)&&(b%2==1)) | |
{ | |
printf("O"); | |
} | |
else | |
printf("*"); | |
} | |
printf("\n"); | |
} | |
} | |
4. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int a=0;a<=5;a++) | |
{ | |
for(int b=0;b<=29;b++) | |
{ | |
if((a%2==1)&&((b%3==0)||(b%5==0))) | |
{ | |
printf("*"); | |
} | |
else | |
{ | |
printf("O"); | |
} | |
} | |
printf("\n"); | |
} | |
} | |
5. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int p=1;p<=3;p++) | |
{ | |
for(int a=1;a<=15;a++) | |
{ | |
printf("*"); | |
} | |
printf("\n"); | |
for(int b=1;b<=4;b++) | |
{ | |
if(p==3) | |
break; | |
printf("*OOOO"); | |
} | |
printf("\n"); | |
} | |
} | |
6. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int a=0;a<=10;a++) | |
{ | |
for(int b=0;b<=16;b++) | |
{ | |
if | |
{ | |
printf("*"); | |
} | |
else | |
printf("O"); | |
} | |
printf("\n"); | |
} | |
} | |
7. | |
#include<stdio.h> | |
void main() | |
{ | |
printf("OOOOOOOOOOOOOOOOOO\n"); | |
printf("OOOOOO****OOOOOO\n"); | |
printf("OOOO*******OOOO\n"); | |
printf("OOO********OOO\n"); | |
for(int b=1;b<=3;b++) | |
{ | |
printf("OO********OO\n"); | |
} | |
printf("OOO********OOO\n"); | |
printf("OOOO*******OOOO\n"); | |
printf("OOOOOO****OOOOOO\n"); | |
printf("OOOOOOOOOOOOOOOOOO\n"); | |
} | |
8. | |
#include<stdio.h> | |
void main() | |
{ | |
int p=3; | |
for(int a=0;a<10;a++) | |
{ | |
for(int b=0;b<20;b++) | |
{ | |
if(((a>1)&&(a<8)&&((a+b)>=8)&&((a+b)<=p))||(a==9)||(a==8)) | |
{ | |
printf("O"); | |
} | |
else | |
{ | |
printf("*"); | |
} | |
} | |
p=p+3; | |
printf("\n"); | |
} | |
} | |
9. | |
#include<stdio.h> | |
void main() | |
{ | |
int p=11; | |
for(int a=0;a<=10;a++) | |
{ | |
for(int b=0;b<20;b++) | |
{ | |
if((a+b)>6)&&((a+b)<=p)||(a==9)||(a==10) | |
{ | |
printf("*"); | |
} | |
else | |
printf("O"); | |
} | |
printf("\n"); | |
p++; | |
} | |
} | |
10. | |
#include<stdio.h> | |
void main() | |
{ for(int m=1;m<=2;m++) | |
{ | |
for(int a=1;a<=20;a++) | |
{ | |
printf("*"); | |
} | |
printf("\n"); | |
} | |
int l=6,k=2,j=12; | |
for(int b=1;b<=6;b++) | |
{ | |
for(int w=1;w<=l;w++) | |
{ | |
printf("*"); | |
} | |
for(int q=1;q<=k;q++) | |
{ | |
printf("0"); | |
} | |
for(int r=1;r<=j;r++) | |
{ | |
printf("*"); | |
} | |
k=k+3; | |
l--; | |
j=j-2; | |
printf("\n"); | |
} | |
for(int m=1;m<=2;m++) | |
{ | |
for(int a=1;a<=20;a++) | |
{ | |
printf("0"); | |
} | |
printf("\n"); | |
} | |
} | |
11. | |
#include<stdio.h> | |
void main() | |
{ | |
int l=1,k=6,j=1,h=5; | |
printf("OO*"); | |
for(int a=1;a<=6;a++) | |
{ | |
printf("O*"); | |
} | |
printf("\n"); | |
for(int b=1;b<=5;b++) | |
{ | |
for(int c=1;c<=l;c++) | |
{ | |
printf("OO"); | |
} | |
printf("*"); | |
for(int d=1;d<=k;d++) | |
{ | |
printf("O*"); | |
} | |
printf("\n"); | |
if(b<5) | |
{ | |
for(int e=1;e<=j;e++) | |
{ | |
printf("**"); | |
} | |
printf("OO*"); | |
for(int f=1;f<=h;f++) | |
{ | |
printf("O*"); | |
} | |
h--; | |
l++; | |
k--; | |
j++; | |
printf("\n"); | |
} | |
} | |
} | |
assignment no.6 | |
1. | |
#include<stdio.h> | |
void main() | |
{ | |
for(char a='E';a>='A';a--) | |
{ | |
for(int b='A';b<=a;b++) | |
{ | |
printf("%c",b); | |
} | |
printf("\n"); | |
} | |
} | |
2. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int b=69;b>=65;b--) | |
{ | |
for(int a=b;a>=65;a--) | |
{ | |
printf("%c",a); | |
} | |
printf("\n"); | |
} | |
} | |
3. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int a=65;a<=69;a++) | |
{ | |
for(int b=a;b<=69;b++) | |
{ | |
printf("%c",a); | |
} | |
printf("\n"); | |
} | |
} | |
4. | |
#include<stdio.h> | |
void main() | |
{ | |
int p=69,m=73; | |
for(int a=1;a<=5;a++) | |
{ | |
for(int b=p;b<=m;b++) | |
{ | |
printf("%c",b); | |
} | |
m=m-2; | |
p--; | |
printf("\n"); | |
} | |
} | |
5. | |
#include<stdio.h> | |
void main() | |
{ | |
int p=65,m=69; | |
for (int a=1;a<=5;a++) | |
{ | |
for(int b=m;b>=p;b--) | |
{ | |
printf("%c",b); | |
} | |
m++; | |
p=p+2; | |
printf("\n"); | |
} | |
} | |
6. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int a=69;a>=65;a--) | |
{ | |
for(int b=65;b<=a;b++) | |
{ | |
printf("%c",a); | |
} | |
printf("\n"); | |
} | |
} | |
7. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int b=1;b<=5;b++) | |
{ | |
for(int a=1;a<=b;a++) | |
{ | |
printf("A"); | |
} | |
printf("\n"); | |
} | |
} | |
8. | |
#include<stdio.h> | |
void main() | |
{ | |
int a,n; | |
printf("Enter any number="); | |
scanf("%d",&n); | |
while(n<0) | |
{ | |
printf("Enter any number again"); | |
scanf("%d",&a); | |
if(a<0) | |
{ | |
continue; | |
} | |
else | |
{ | |
break; | |
} | |
} | |
} | |
9. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int a=1;a<=9;a=a+2) | |
{ | |
for(int b=1;b<=a;b++) | |
{ | |
printf("A"); | |
} | |
printf("\n"); | |
} | |
} | |
10. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int a=10;a>=2;a=a-2) | |
{ | |
for(int b=1;b<=a;b++) | |
{ | |
printf("A"); | |
} | |
printf("\n"); | |
} | |
} | |
11. | |
#include<stdio.h> | |
void main() | |
{ | |
int p=0; | |
for (int a=65;a<=70;a++) | |
{ | |
p++; | |
for(int b=a;b<=70;b++) | |
{ | |
printf("%c",b); | |
} | |
printf("\n"); | |
for(int c=1;c<=p;c++) | |
{ | |
printf(" "); | |
} | |
} | |
} | |
12. | |
#include<stdio.h> | |
void main() | |
{ | |
int p=101; | |
for(int a=65;a<=70;a++) | |
{ | |
for(int c=65;c<=a;c++) | |
{ | |
printf("%c",c); | |
} | |
for(int b=97;b<=p;b++) | |
{ | |
printf("%c",b); | |
} | |
p--; | |
printf("\n"); | |
} | |
} | |
13. | |
#include<stdio.h> | |
void main() | |
{ | |
int p=65; | |
for(int a=65;a<=70;a++) | |
{ | |
for(int b=a;b<=p;b++) | |
{ | |
printf("%c",b); | |
} | |
p=p+2; | |
printf("\n"); | |
} | |
} | |
16. | |
#include<stdio.h> | |
void main() | |
{ | |
int m,p=1,r=7; | |
for(int b=1;b<=6;b++) | |
{ | |
m=1; | |
for(int a=65;a>=64;a=a+p) | |
{ | |
if(m==r) | |
{ | |
break; | |
} | |
printf("%c",a); | |
m++; | |
} | |
printf("\n"); | |
p++; | |
r--; | |
} | |
} | |
17. | |
#include<stdio.h> | |
void main() | |
{ | |
int n=1,p=65; | |
for(int w=1;w<=6;w++) | |
{ | |
for(int a=p;a<=70;a++) | |
{ | |
for(int m=1;m<=n;m++) | |
printf("%c",a); | |
} | |
p++; | |
printf("\n"); | |
n++; | |
} | |
} | |
18. | |
#include<stdio.h> | |
void main() | |
{ | |
int p=65,r=5; | |
for(int m=1;m<=5;m++) | |
{ | |
for(int n=1;n<=r;n++) | |
{ | |
printf(" "); | |
} | |
for(int a=65;a<=p;a++) | |
{ | |
printf("%c",a); | |
} | |
for(int b=p-1;b>=65;b--) | |
{ | |
printf("%c",b); | |
} | |
printf("\n"); | |
p++; | |
r--; | |
} | |
} | |
19. | |
#include<stdio.h> | |
void main() | |
{ | |
int m=70,p=6; | |
for(int n=1;n<=6;n++) | |
{ | |
for(int b=1;b<=p;b++) | |
{ | |
printf(" "); | |
} | |
for(int a=m;a<=70;a++) | |
{ | |
printf("%c",a); | |
} | |
p--; | |
m--; | |
printf("\n"); | |
} | |
} | |
20. | |
#include<stdio.h> | |
void main() | |
{ | |
int p=66,m=67,n=3; | |
printf("A\n"); | |
for(int a=1;a<=5;a++) | |
{ | |
for(int b=p;b<=m;b++) | |
{ | |
printf("%c",b); | |
} | |
printf("\n"); | |
p=m+1; | |
m=m+n; | |
n++; | |
} | |
} | |
24. | |
#include<stdio.h> | |
void main() | |
{ | |
int p=0; | |
for(int a=65;a<=86;a=a+p) | |
{ | |
printf("%c",a); | |
p++; | |
} | |
} | |
25. | |
#include<stdio.h> | |
void main() | |
{ | |
for(int a=1;a<=6;a++) | |
{ | |
printf("%d",a); | |
printf(","); | |
} | |
} | |
26. | |
#include<stdio.h> | |
void main() | |
{ | |
int p=7; | |
for(int b=4;b<=10;b++) | |
{ | |
for(int a=0;a<=p;a++) | |
{ | |
printf("%d",b*a); | |
printf(","); | |
} | |
if(p>3) | |
{ | |
p--; | |
} | |
printf("\n"); | |
} | |
} | |
assignment no.7 | |
1. | |
#include<stdio.h> | |
void main() | |
{ | |
int a,b,c,d; | |
printf("Enter any number="); | |
scanf("%d %d %d %d",&a,&b,&c,&d); | |
printf("%d\t",a); | |
printf("%d",b); | |
printf("\n%d\t",c); | |
printf("%d",d); | |
} | |
2. | |
#include<stdio.h> | |
void main() | |
{ | |
int a,b,c,d,e,f; | |
printf("Enter any number="); | |
scanf("%d %d",&a,&c); | |
d=c; | |
e=c; | |
f=c; | |
b=a; | |
int m=0; | |
int g; | |
g=c; | |
for(int n=1;n>=1;n++) | |
{ | |
if(c>=0) | |
{ | |
c=c/10; | |
m++; | |
} | |
if(c==0) | |
{ | |
break; | |
} | |
} | |
for(int q=1;q<=2;q++) | |
{ | |
printf("%d",a); | |
for(int w=1;w<=m;w++) | |
{ | |
printf(" "); | |
} | |
} | |
printf("\n"); | |
for(int t=1;t<=2;t++) | |
{ | |
for(int r=1;r<=2;r++) | |
{ | |
printf("%d ",g); | |
} | |
printf("\n"); | |
} | |
} | |
4. | |
#include<stdio.h> | |
void main() | |
{ | |
float a,b,c,d; | |
printf("Enter co-ordinate of lines="); | |
scanf("%f %f %f %f",&a,&b,&c,&d); | |
printf("mid point=%f %f",(a+c)/2,(b+d)/2); | |
} | |
5. | |
#include<stdio.h> | |
void main() | |
{ | |
float a,b,c; | |
printf("Enter 1st vector="); | |
scanf("%f %f %f",&a,&b,&c); | |
printf("%fi+%fj+%fk\n",a,b,c); | |
float p,q,r; | |
printf("Enter 2nd vector="); | |
scanf("%f %f %f",&p,&q,&r); | |
printf("%fi+%fj+%fk\n",p,q,r); | |
printf("%0.1f",p*a+q*b+r*c); | |
} | |
6. | |
#include<stdio.h> | |
#include<math.h> | |
void main() | |
{ | |
float a,b,c; | |
printf("Enter 1st vector="); | |
scanf("%f %f %f",&a,&b,&c); | |
float t=a*a+b*b+c*c; | |
float r=sqrt(t); | |
printf("%0.1fi+%0.1fj+%0.1fk\n",a/r,b/r,c/r); | |
} | |
7. | |
#include<stdio.h> | |
void main() | |
{ | |
float a,b,c; | |
printf("Enter 1st vector="); | |
scanf("%f %f %f",&a,&b,&c); | |
printf("%fi+%fj+%fk\n",a,b,c); | |
float p,q,r; | |
printf("Enter 2nd vector="); | |
scanf("%f %f %f",&p,&q,&r); | |
printf("%fi+%fj+%fk\n",p,q,r); | |
float x,y,z; | |
x=b*r-c*b; | |
y=a*r-p*c; | |
z=a*q-b*p; | |
printf("%f %f %f",x,y,z); | |
} | |
11. | |
#include<stdio.h> | |
void main() | |
{ | |
float a,b,c; | |
printf("Enter coff. of x,y and constant="); | |
scanf("%f %f %f",&a,&b,&c); | |
printf("Equation of line : %0.1fx+%0.1fy+%0.1f=0\n",a,b,c); | |
float x; | |
x=-c/a; | |
printf("Intersection of the line on x-axis::%0.1f",x); | |
} | |
12. | |
#include<stdio.h> | |
void main() | |
{ | |
int a,b; | |
printf("Enter real & imaginary part of umber="); | |
scanf("%d %d",&a,&b); | |
if((a>0)&&(b>0)) | |
{ | |
printf("%d+%di\n",a,b); | |
printf("Nice looking form"); | |
} | |
else if((a==0)&&(b!=0)) | |
{ | |
printf("%di\n",b); | |
printf("Nice looking form"); | |
} | |
else if((a!=0)&&(b==0)) | |
{ | |
printf("%d",a); | |
printf("\n"); | |
printf("Nice looking form"); | |
} | |
else if((a<0)&&(b>0)) | |
{ | |
printf("%d+%di\n",a,b); | |
printf("Nice looking form"); | |
} | |
else if((a>0)&&(b<0)) | |
{ | |
printf("%d%di\n",a,b); | |
printf("Nice looking form"); | |
} | |
13. | |
#include<stdio.h> | |
void main() | |
{ | |
int a,b,c; | |
printf("Enter i,j,k of vector"); | |
scanf("%d %d %d",&a,&b,&c); | |
if((b==0)&&(c>0)) | |
{ | |
printf("%di+%dk",&a,&c); | |
} | |
else if((b==0)&&(c<0)) | |
{ | |
printf("%di%dk",&a,&c); | |
} | |
if((b>0)&&(c>0)) | |
{ | |
printf("%di+%dj+%dk",&a,&b,&c); | |
} | |
else if((b<0)&&(c>0)) | |
{ | |
printf("%di%dj+%dk",&a,&b,&c); | |
} | |
else if((b>0)&&(c<0)) | |
{ | |
printf("%di+%dj%dk",&a,&b,&c); | |
} | |
else | |
{ | |
printf("%di%dj%dk",&a,&b,&c); | |
} | |
} | |
14. | |
#include<stdio.h> | |
void main() | |
{ | |
int n; | |
printf("Enter number of input="); | |
scanf("%d",&n); | |
int ch[n]; | |
printf("Enter entries="); | |
for(int a=0;a<n;a++) | |
{ | |
scanf("%d",&ch[a]); | |
} | |
for(int b=0;b<n;b++) | |
{ | |
printf("%d",ch[b]); | |
printf(","); | |
} | |
int p=0; | |
for(int c=0;c<n;c++) | |
{ | |
p=p+ch[c]; | |
} | |
printf("\n sum=%d",p); | |
} | |
15. | |
#include<stdio.h> | |
void main() | |
{ | |
int n; | |
printf("Enter number of input="); | |
scanf("%d",&n); | |
int ch[n]; | |
printf("Enter entries="); | |
for(int a=0;a<n;a++) | |
{ | |
scanf("%d",&ch[a]); | |
} | |
for(int b=0;b<n;b++) | |
{ | |
printf("%d",ch[b]); | |
if(b<(n-1)) | |
printf(","); | |
} | |
int p=0; | |
for(int c=0;c<n;c++) | |
{ | |
p=p+ch[c]; | |
} | |
printf("\n sum=%d",p); | |
} | |
16. | |
#include<stdio.h> | |
void main() | |
{ | |
int n; | |
printf("Enter number of input="); | |
scanf("%d",&n); | |
int ch[n]; | |
printf("Enter entries="); | |
for(int a=0;a<n;a++) | |
{ | |
scanf("%d",&ch[a]); | |
} | |
for(int b=0;b<n;b++) | |
{ | |
printf("%d",ch[b]); | |
if(b==0) | |
{ | |
printf(";"); | |
} | |
if((b<(n-1))&&(b!=0)) | |
printf(","); | |
} | |
int p=0; | |
for(int c=0;c<n;c++) | |
{ | |
p=p+ch[c]; | |
} | |
printf("\n sum=%d",p); | |
} | |
17. | |
#include<stdio.h> | |
void main() | |
{ | |
int n; | |
printf("Enter number of input="); | |
scanf("%d",&n); | |
int ch[n]; | |
printf("Enter entries="); | |
for(int a=0;a<n;a++) | |
{ | |
scanf("%d",&ch[a]); | |
} | |
for(int b=0;b<n;b++) | |
{ | |
printf("%d",ch[b]); | |
if(b==0) | |
{ | |
for(int m=0;m<=4;m++) | |
printf(";"); | |
} | |
if((b<(n-1))&&(b!=0)) | |
printf(","); | |
} | |
int p=0; | |
for(int c=0;c<n;c++) | |
{ | |
p=p+ch[c]; | |
} | |
printf("\n sum=%d",p); | |
} | |
18. | |
#include<stdio.h> | |
#include<math.h> | |
void main() | |
{ | |
int n; | |
printf("Enter dimension="); | |
scanf("%d",&n); | |
float ch[n]; | |
printf("Enter entries="); | |
for(int a=0;a<n;a++) | |
{ | |
scanf("%f",&ch[a]); | |
} | |
float p=0; | |
for(int c=0;c<n;c++) | |
{ | |
p=p+ch[c]*ch[c]; | |
} | |
float q=sqrt(p); | |
printf("\n modulus=%f",q); | |
} | |
19. | |
#include<stdio.h> | |
void main() | |
{ | |
int ch[2]; | |
int p,n=0; | |
for(int a=1;a<=4;a++) | |
{ | |
p=1; | |
printf("Enter pair="); | |
for(int b=0;b<=1;b++) | |
{ | |
scanf("%d",&ch[b]); | |
p=p*ch[b]; | |
} | |
n=n+p; | |
} | |
printf("%d",n); | |
} | |
23. | |
#include<stdio.h> | |
void main() | |
{ | |
int a; | |
printf("Enter number="); | |
scanf("%d",&a); | |
for(int q=1;q>=1;q++) | |
{ | |
a=a/10; | |
if((a>0)&&(a<10)) | |
break; | |
} | |
int b; | |
printf("Enter number="); | |
scanf("%d",&b); | |
for(int r=1;r>=1;r++) | |
{ | |
b=b/10; | |
if((b>0)&&(b<10)) | |
break; | |
} | |
printf("%d",a*b); | |
} | |
24. | |
#include<stdio.h> | |
void main() | |
{ | |
int a; | |
printf("Enter any number="); | |
scanf("%d",&a); | |
a=a/1000; | |
int b; | |
b=a%10; | |
printf("%d",b); | |
} | |
26. | |
#include<stdio.h> | |
#include<math.h> | |
void main() | |
{ | |
int a,b; | |
printf("Enter numbers="); | |
scanf("%d %d",&a,&b); | |
int m=pow(10,b-1); | |
a=a/m; | |
int q=a%10; | |
printf("%d",q); | |
} | |
assignment no.8 | |
1. | |
#include<stdio.h> | |
void main() | |
{ | |
int i,n,x,y,sum=0; | |
printf("give n:"); | |
scanf("%d",&n); | |
printf("give %d numbers:",n); | |
for(i=1;i<=n;i++) | |
{ | |
scanf("%d",&x); | |
y=x%10; | |
sum=sum+y; | |
} | |
printf("%d",sum); | |
} | |
2. | |
#include<stdio.h> | |
void main() | |
{ | |
int i,n,x,y,sum=0; | |
printf("give n:"); | |
scanf("%d",&n); | |
printf("give %d numbers:",n); | |
for(i=1;i<=n;i++) | |
{ | |
scanf("%d",&x); | |
y=x/10; | |
sum=sum+y; | |
} | |
printf("%d",sum); | |
} | |
3. | |
#include<stdio.h> | |
void main() | |
{ | |
int i,n,x,y,z,sum=0; | |
printf("give n:"); | |
scanf("%d",&n); | |
printf("give %d numbers:",n); | |
for(i=1;i<=n;i++) | |
{ | |
scanf("%d",&x); | |
y=x/10; | |
z=y%10; | |
sum=sum+z; | |
} | |
printf("%d",sum); | |
} | |
4. | |
#include<stdio.h> | |
void main() | |
{ | |
int i,n,x,y,m,k,z,sum=0; | |
printf("give n:"); | |
scanf("%d",&n); | |
printf("give %d numbers:",n); | |
for(i=1;i<=n;i++) | |
{ | |
scanf("%d",&x); | |
y=x/10; | |
z=y/10; | |
k=x%10; | |
m=(z*10)+k; | |
sum=sum+m; | |
} | |
printf("%d",sum); | |
} | |
5. | |
#include<stdio.h> | |
void main() | |
{ | |
int i,n,x,y,z,k,m,sum=0; | |
printf("give n:"); | |
scanf("%d",&n); | |
printf("give %d numbers:",n); | |
for(i=1;i<=n;i++) | |
{ | |
scanf("%d",&x); | |
y=x%10; | |
z=x/10; | |
m=z%10; | |
k=(y*m); | |
sum=sum+k; | |
} | |
printf("%d",sum); | |
} | |
6. | |
#include<stdio.h> | |
void main() | |
{ | |
int i,n,x,y,z,m,k,p,sum=0; | |
printf("give n:"); | |
scanf("%d",&n); | |
printf("give %d numbers:",n); | |
for(i=1;i<=n;i++) | |
{ | |
scanf("%d",&x); | |
y=x/10; | |
z=x%10; | |
k=y/10; | |
m=y%10; | |
p=(k*100)+(z*10)+m; | |
sum=sum+p; | |
} | |
printf("%d",sum); | |
} | |
7. | |
#include<stdio.h> | |
void main() | |
{ | |
int i,n,x,a; | |
printf("give n:"); | |
scanf("%d",&n); | |
printf("give %d numbers:",n); | |
for(i=1;i<=n;i++) | |
{ | |
scanf("%d",&x); | |
if(x%2==0) | |
a=x; | |
} | |
printf("%d",a); | |
} | |
8. | |
#include<stdio.h> | |
void main() | |
{ | |
int i,n,x,a,sum=0; | |
printf("give n:"); | |
scanf("%d",&n); | |
printf("give %d numbers:",n); | |
for(i=1;i<=n;i++) | |
{ | |
scanf("%d",&x); | |
a=(i*x); | |
sum=sum+a; | |
} | |
printf("%d",sum); | |
} | |
9. | |
#include<stdio.h> | |
void main() | |
{ | |
int i,n,x,a,sum=0; | |
printf("given:"); | |
scanf("%d",&n); | |
printf("give %d numbers:",n); | |
for(i=1;i<=n;i++) | |
{ | |
scanf("%d",&x); | |
a=x; | |
if(a%2!=0) | |
sum=sum+a; | |
} | |
printf("%d",sum); | |
} | |
10. | |
#include<stdio.h> | |
void main() | |
{ | |
int i,n,x,a,q=0; | |
printf("give n:"); | |
scanf("%d",&n); | |
printf("give %d numbers:",n); | |
for(i=1;i<=n;i++) | |
{ | |
scanf("%d",&x); | |
a=x; | |
if(a%2!=0) | |
q++; | |
} | |
printf("%d",q); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment