You are on page 1of 14

LAB ASSIGNMENT-03

NAME : JAKIA RAHMAN

ID : C-201234

DEPERTMENT OF CSE

CSE-1122

SEMESTER : 1ST (SPRING-2020)


Problem no. 01 : Write a C program to determine yhe largest
number among three numbers .

Solution :

#include <stdio.h>

int main() {

int n1, n2, n3;

printf("Enter three different numbers: ");

scanf("%d %d %d", &n1, &n2, &n3);

if (n1 >= n2 && n1 >= n3)

printf("%d is the largest number.", n1);

if (n2 >= n1 && n2 >= n3)

printf("%d is the largest number.", n2);

if (n3 >= n1 && n3 >= n2)

printf("%d is the largest number.", n3);

return 0;

}
Problem no. 02 : Write a C program to check whether the
triangle is equilateral,isosceles,or scalene .

Solution :
#include<stdio.h>

int main(){

int side1,side2,side3;

printf("Enter all 3 sides of the triangle : ");

scanf("%d %d %d",&side1,&side2,&side3);

if(side1==side2&&side2==side3)

{printf("IT IS AN EQUILATERAL TRIANGLE . ");}

else if(side1==side2||side1==side3||side2==side3)

{printf("IT IS AN ISOSCELES TRIANGLE . ");}

else

{printf("IT IS A SCALENE TRIANGLE . ");}

return 0;

}
Problem no. 03 : Write a C program to check a number
whether it is divisible by 5 and 11 or not .

Solution :
#include <stdio.h>

int main()

int num;

printf("Enter a integer number : ");

scanf("%d", &num);

if((num % 5 == 0) && (num % 11 == 0))

printf(" The integer number is divisible by 5 and 11");

else

printf("The integer number is not divisible by 5 and 11");

return 0;

}
Problem no. 04 : Write a C program to check whether it is a
leap year or not .

Solution :
#include<stdio.h>

int main(){

int year;

printf("Enter a year : ");

scanf("%d",&year);

if(year%4==0)

if(year%100==0)

if(year%400==0)

printf("%d is a leap year . ");

else

printf("%d is not a leap year . ");

else
printf("%d is a leap year . ");

else

printf("%d is not a leap year . ");

return 0;

}
Problem no. 05 : Write a C program to input any alphabet and
check whether it is vowel or alphabet.

Solution :
#include <stdio.h>

int main()

char ch;

printf("Enter a character\n");

scanf("%c", &ch);

if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch =='o'


|| ch=='O' || ch == 'u' || ch == 'U')

printf("%c is a vowel.\n", ch);

else

printf("%c is a consotant.\n", ch);

return 0;

}
Problem no. 06 : Write a C program to input any alphabet and
check whether it is uppercase or lowercase .

Solution :
#include<stdio.h>

int main(){

char ch;

printf("Enter an alphabet : ");

scanf("%c",&ch);

if(ch>='a' && ch<='z')

printf("%c is lower case alphabet\n",ch);

if(ch>='A' && ch<='Z')

printf("%c is uppercase alphabet\n",ch);

return 0;

}
Problem no. 07 : Write a C program to input a character and
check whether it is an alphabet ,digit or special character .

Solution :
int main(){

char ch;

printf("Enter a character : ");

scanf("%c",&ch);

if((ch>='a'&& ch<='z')|| (ch>='A'&& ch<='B'))

printf("%c IS AN ALPHABET\n",ch);

else if(ch >= '0' && ch <= '9')

printf("'%c' IS A DIGIT.", ch);

else

printf("'%c' IS SPECIAL CHARACTER.", ch);

return 0;

}
Problem no. 08 : Write a C program to find
maximum,minimum,middle from three numbers.

Solution :

#include<stdio.h>

int main()

int a,b,c;

printf("enter the three values=");

scanf("%d%d%d",&a,&b,&c);

if(a>b)

if(a>c)

if(c>b)

printf("maximum , middle, minimum is %d%d


%d",a,c,b);

else

printf("maximum , middle, minimum is %d%d


%d",a,b,c);
}

else

printf("maximum , middle, minimum is %d%d%d",c,a,b);

else

if(b>c)

if(c>a)

printf("maximum , middle, minimum is %d%d


%d",b,c,a);

else

printf("maximum , middle, minimum is %d%d


%d",b,a,c);

else

printf("maximum , middle, minimum is %d%d%d",c,b,a);


}

return 0;

}
Problem no. 09 : Write a C program to input marks of five
subjects and calculate percentage and grade .

Solution :
#include<stdio.h>

int main(){

int physics,chemistry,biology,math,computer,total,average;

printf("Enter the marks of all subjects : ");

scanf("%d%d%d%d%d",&physics,&chemistry,&biology,&math,&computer);

total=physics+chemistry+biology+math+computer;

average=total/5;

printf("The total marks is : %d\n",total);

printf("The average marks is : %d\n",average);

if(average>=90)

{printf("THE GRADE IS A.");}

else if(average>=80)

{printf("THE GRADE IS B.");}

else if(average>=70)

{printf("THE GRADE IS C.");}


else if(average>=60)

{printf("THE GRADE IS D.");}

else if(average>=40)

{printf("THE GRADE IS E.");}

else if(average<=40)

{printf("THE GRADE IS F.");}

else

{printf("Enter a valid number");}

return 0;

You might also like