Archive for the ‘Lab 11A’ Category

#include<stdio.h>
int main()
{
    int d1,d2,d3,d4,d5,sum;
    long num;
    printf("Enter a five digit number: ");
    scanf("%ld",&num);
    d1=(num%10);
    d2=(num%100)/10;
    d3=(num%1000)/100;
    d4=(num%10000)/1000;
    d5=(num/1000);
    sum=d1+d2+d3+d4+d5;
    printf("\n The sum of the digis is: %d",sum);
	return 0;
}
Advertisements
#include<stdio.h>
int main()
{
	int days;
	scanf("%d",&days);
	if(days<=5)
		printf("Fine is 50 paise");
else	if(days>5&&days<=10)
printf("Fine is 1 rupee");
	else if(days>10&&days<=30)
		printf("Fine is 5 rupee");
else	if(days>30)
		printf("Membership cancelled");
	return 0;
}
    #include<stdio.h>
    int main()
    {
    char ch;
    printf("Enter a character");
    scanf("%c",&ch);
    if((ch>=65)&&(ch<=90))		
printf("Capital Lette\nr"); 
	else if((ch>=97)&&(ch<=122))
		printf("Small Letter\n");
		else if((ch>=48)&&(ch<=57))
		printf("Number\n");
		else if(((ch>=0)&&(ch<=47))||((ch>=58)&&(ch<=64))||((ch>=91)&&(ch<=96))||((ch>=123)&&(ch<=127)))
	printf("Enter Special Symbol\n");
    return 0;
    }

    #include<stdio.h>
    int main()
    {
    char ch;
    printf("Enter a character");
    scanf("%c",&ch);
    if((ch>=65)&&(ch<=122))
		{
    ch=ch-32;
    printf("The upper case character corresponding is=%c\n",ch);
}
	else
		printf("Enter Invalid");
    return 0;
    }

    #include<stdio.h>
    int main()
    {
    char ch;
    printf("Enter a character");
    scanf("%c",&ch);
    if((ch>=65)&&(ch<=122))
		{
    ch=ch+32;
    printf("The lower case character corresponding is %c\n",ch);
}
	else 
		printf("Enter Invalid");
    return 0;
    }
#include<stdio.h>
int main()
{
	int i;
	float base,height,area,width,length,area1,side,area2,radius,area3;
	scanf("%d",&i);
	switch(i)
	{
		case 1:
	printf("Enter Base:");
			scanf("%f",&base);
			printf("Enter Height");
			scanf("%f",&height);
			area=0.5*base*height;
			printf("Area of Triangle=%f\n",area);
			break;
		case 3:
			printf("Enter Width:");
				scanf("%f",&width);
				printf("Enter Length:");
				scanf("%f",&length);
				area1=width*length;
				printf("Area of rectangle=%f\n",area1);
				break;
	    case 7:
                printf("Enter Side:");
				scanf("%f",&side);
				area2=side*side;
				printf("Area of Square=%f\n",area2);
			break;
default:
			printf("Enter radius:");
			scanf("%f",&radius);
			area3=3.14*radius*radius;
			printf("Area of Circle=%f\n",area3);
		}
	return 0;
}
#include<stdio.h>
int main()
{
	float area,base,height,area_rec,width;
	printf("Area:");
	scanf("%f",&area);
	printf("Base:");
	scanf("%f",&base);
	height=((2*area)/base);
	printf("Height=%f\n",height);
	printf("Area Of Rectangle:");
	scanf("%f",&area_rec);
	width=area_rec/height;
	printf("Width=%f",width);
	return 0;
	}
#include<stdio.h>   
int main()  
{  
  int a,b;  
  printf("enter the value of a");  
  scanf("%d",&a);  
  if(a<0)  
  {  
   b=a*-1;  
   printf("\nabsolute value of %d is %d",a,b);  
  }  
  else  
   {  
     printf("\nabsolute value=%d",a);  
   }  
   return 0;  
}