rohan's work

6
Task 1: #include <stdio.h> int main( void ) { int i,j,k; printf( "Input three different integers: " ); scanf( "%d %d %d" ,&i,&j,&k); printf( "Sum is %d \n" ,i+j+k); printf( "Average is %d \n" , (i+j+k)/3); printf( "Product is %d \n" , i*j*k); if (i>j && i>k) { printf( "largest %d\n" , i); } if (j>i && j>k) { printf( "largest %d\n" , j); } if (k>i && k>j) { printf( "largest %d\n" , k); } if (i<j && i<k) { printf( "Smallest is %d\n" , i); } if (k<j && k<i) { printf( "Smallest is %d\n" , k); } if (j<k && j<i) { printf( "Smallest is %d\n" , j); } }

Upload: rohaanmanzoor

Post on 23-Jan-2016

1 views

Category:

Documents


0 download

DESCRIPTION

for NUST EE bEE-7B

TRANSCRIPT

Page 1: Rohan's Work

Task 1:#include <stdio.h>

int main(void)

{int i,j,k;printf("Input three different integers: ");scanf("%d %d %d",&i,&j,&k);printf("Sum is %d \n",i+j+k);printf("Average is %d \n", (i+j+k)/3);printf("Product is %d \n", i*j*k);if (i>j && i>k){

printf("largest %d\n", i);}if (j>i && j>k){

printf("largest %d\n", j);}if (k>i && k>j){

printf("largest %d\n", k);}if (i<j && i<k){

printf("Smallest is %d\n", i);}if (k<j && k<i){

printf("Smallest is %d\n", k);}if (j<k && j<i){

printf("Smallest is %d\n", j);}

}

Page 2: Rohan's Work

Task 2:#include <stdio.h>

int main(void)

{int i;int j;

printf("Enter a number:");scanf("%d", &i);

if(i%2==0){

printf("You gave an even number\n");}else if (i%2!=0){

printf("You gave an odd number\n");}

}

Task 3:#include <stdio.h>

int main(void)

{float i;

printf("enter the radius:");scanf("%f",&i);

printf("diameter is: %f\n",2*i);printf("area is: %f\n",3.14159*i*i);printf("circumference is: %f\n",2*i*3.14159);

}

Page 3: Rohan's Work

Task 4:#include <stdio.h>

int main(void)

{int a,b,c,d,e;

printf("Enter your 1st integer:");scanf("%d",&a);printf("Enter your 2nd integer:");scanf("%d",&b);printf("Enter your 3rd integer:");scanf("%d",&c);printf("Enter your 4th integer:");scanf("%d",&d);printf("Enter your 5th integer:");scanf("%d",&e);

if (a>b && a>c && a>d && a>e)printf("Largest integer:%d\n",a);else if (b>a && b>c && b>d && b>e)printf("Largest integer:%d\n",b);else if (c>a && c>b && c>d && c>e)printf("Largest integer:%d\n",c);else if (d>a && d>b && d>c && d>e)printf("Largest integer:%d\n",d);else if (e>a && e>b && e>c && e>d)printf("Largest integer:%d\n",e);

if (a<b && a<c && a<d && a<e)printf("Smallest integer:%d\n",a);else if (b<a && b<c && b<d && b<e)printf("Smallest integer:%d\n",b);else if (c<a && c<b && c<d && c<e)printf("Smallest integer:%d\n",c);else if (d<a && d<b && d<c && d<e)printf("Smallest integer:%d\n",d);else if (e<a && e<b && e<c && e<d)printf("Smallest integer:%d\n",e);

}

Page 4: Rohan's Work

Task 5:#include <stdio.h>

int main(void)

{int i;

printf("Enter a five digit integer:");scanf("%d",&i);

printf("%d ",i/10000);printf("%d ",(i/1000)%10);printf("%d ",(i/100)%10);printf("%d ",(i/10)%10);printf("%d ",i%10);

}

Task 6:#include <stdio.h>

int main(void)

{int i=1;

printf("number\tsqure\tcube\n");printf("%d\t%d\t%d\n",i,i*i,i*i*i);++i;printf("%d\t%d\t%d\n",i,i*i,i*i*i);++i;printf("%d\t%d\t%d\n",i,i*i,i*i*i);++i;printf("%d\t%d\t%d\n",i,i*i,i*i*i);++i;printf("%d\t%d\t%d\n",i,i*i,i*i*i);++i;printf("%d\t%d\t%d\n",i,i*i,i*i*i);++i;printf("%d\t%d\t%d\n",i,i*i,i*i*i);++i;printf("%d\t%d\t%d\n",i,i*i,i*i*i);++i;printf("%d\t%d\t%d\n",i,i*i,i*i*i);++i;printf("%d\t%d\t%d\n",i,i*i,i*i*i);

}

Page 5: Rohan's Work

Task 7:#include <stdio.h>

int main(void)

{printf("y's integer equivalent is: %d \n",'y');printf("A's integer equivalent is: %d \n",'A');printf("a's integer equivalent is: %d \n",'a');printf("B's integer equivalent is: %d \n",'B');printf("b's integer equivalent is: %d \n",'b');printf("C's integer equivalent is: %d \n",'C');printf("c's integer equivalent is: %d \n",'c');printf("0's integer equivalent is: %d \n",'0');printf("1's integer equivalent is: %d \n",'1');printf("2's integer equivalent is: %d \n",'2');printf("$'s integer equivalent is: %d \n",'$');printf("*'s integer equivalent is: %d \n",'*');printf("+'s integer equivalent is: %d \n",'+');printf("/'s integer equivalent is: %d \n",'/');printf("blank space's integer equivalent is: %d \n",' ');

}