6. Assignment 6
#include<stdio.h>
void main()
{
int question;
printf("Surprise Test 6\n");
printf("Enter question number :");
scanf("%d",&question);
switch(question)
{
case 1:;
int num,r;
printf("Enter a number whose 2nd digit to be deleted : ");
scanf("%d",&num);
r=num%10;
num=num/100;
num=num*10+r;
printf("Num = %d",num);
break;
case 2:;
unsigned int numb,i,pos=3;
printf("Enter a number whose 3rd bit to be deleted : ");
scanf("%d",&numb);
i=numb<<(32-pos);
i=i>>(32-pos);
numb=numb>>(pos+1);
numb=numb<<pos;
numb=i|numb;
printf("Final Number : %d \n",numb);
break;
case 3:;
int fpe;
printf("Name : Chinmay Garud\nID :v23be9c3\n");
fpe=2/0;
break;
case 4:;
int ac,ar,radius,length,breadth,height,base;
float at;
printf("Enter radius of circle : ");
scanf("%d",&radius);
ac=3.14 * radius * radius;
printf("Area of Circle : %d\n",ac);
printf("Enter length of rectangle : ");
scanf("%d",&length);
printf("Enter breadth of rectangle : ");
scanf("%d",&breadth);
ar=length*breadth;
printf("Area of rectangle : %d\n",ar);
printf("Enter height of triangle : ");
scanf("%d",&height);
printf("Enter base of triangle : ");
scanf("%d",&base);
at = 0.5f * height * base;
printf("Area of triangle : %f\n",at);
break;
case 5:;
float f,c;
printf("Enter farhenheit value: ");
scanf("%f",&f);
c=0.555555556 * (f-32);
printf("Celcius value of %f is %f \n",f,c);
break;
case 6:;
int number,r1,temp,rev=0;
printf("Enter 3 digit number :");
scanf("%d",&number);
temp=number;
for( ;number;number=number/10)
{
r=number%10;
rev=rev*10+r;
}
printf("Reverse of %d is %d\n",temp,rev);
break;
}
}
Comments
Post a Comment