Professional Documents
Culture Documents
MD Imrajul Alam Computer Science & Engineering C Cse-Ii I 1,2,3,4,5
MD Imrajul Alam Computer Science & Engineering C Cse-Ii I 1,2,3,4,5
MD Imrajul Alam Computer Science & Engineering C Cse-Ii I 1,2,3,4,5
(ESCS - 291)
CSE – 2nd Sem. – 1st Year
MD IMRAJUL ALAM
NAME: …………………………………………………………………………………………………………..
2ND
20/CSE/002 SEM: …….…….…
ROLL NO: .……………..….…… C
GRP: ….…… CSE-II
SECTION: ……..........
I
ASSIGNMENT NO: ………..……PROGRAM NO: …..………………………………………....
1,2,3,4,5
TITLE / OBJECTIVE:
-If-Else
……….………………………………………………………………………………..................................
………….……………………………………………………………………………..................................
………….……………………………………………………………………………..................................
………….……………………………………………………………………………..................................
Program: PR01.c
#include <stdio.h>
int main()
{
printf("\t\t****EVEN OR ODD****\t\t\n\n");
int num;
printf("\nEnter the number: ");
scanf("%d", &num);
if(num % 2 == 0)
{
printf("\n%d is a even number.", num);
}
else
{
printf("\n%d is a odd number.", num);
}
return 0;
}
OUTPUT:
****EVEN OR ODD****
****EVEN OR ODD****
Program: PR02.c
#include<stdio.h>
int main()
{
printf("\t\t*****FIND THE LARGEST NUMBER*****\n\n");
int a,b,c,big;
big=a;
if(b>big)
{
big=b;
}
if(c>big)
{
big=c;
}
return 0;
}
OUTPUT:
3. Write a Program in C to enter marks of five subjects. Find the Sum and the Average of them
and then assign grade to the students according to the rule below
AVG GRADE
>=90% to <=100% O
>=80% to <=89% E
>=70% to <=79% A
>=60% to <=69% B
>=50% to <=59% C
>=40% to <=49% D
<40% FAIL
Program: PR03.c
#include <stdio.h>
int main()
{
printf("\t\t****RESULTS****\t\t\n\n");
int physics,chemistry,mathematics,biology,statistics;
int sum;
float average;
}
printf("Enter marks of biology: ");
scanf("%d", &biology);
if(biology>100)
{
printf("Enter marks which is not more than 100\n");
printf("Enter marks of biology again: ");
scanf("%d", &biology);
}
printf("Enter marks of statistics: ");
scanf("%d", &statistics);
if(statistics>100)
{
printf("Enter marks which is not more than 100\n");
printf("Enter marks of statistics again: ");
scanf("%d", &statistics);
}
return 0;
}
OUTPUT:
****RESULTS****
****RESULTS****
****RESULTS****
****RESULTS****
****RESULTS****
****RESULTS****
****RESULTS****
****RESULTS****
Program: PR04.c
#include <stdio.h>
int main()
{
printf("\t\t****LEAP YEAR OR NOT****\t\t\n\n");
int year;
printf("Enter the year: ");
scanf("%d", &year);
if (year % 400 == 0)
{
printf("This is a leap year and it has 366 days.");
}
else if (year % 4 == 0)
{
printf("This is a leap year and it has 366 days.");
}
else
{
printf("This is a not leap year and it has 365 days.");
}
return 0;
}
OUTPUT:
Program: PR05.c
#include <stdio.h>
#include <math.h>
int main()
{
double a, b, c;
printf("Enter the first coefficients a: ");
scanf("%lf", &a);
discriminant = b * b - 4 * a * c;
if (discriminant > 0)
{
printf("The real and different roots are: \n");
root1 = (-b + sqrt(discriminant)) / (2 * a);
root2 = (-b - sqrt(discriminant)) / (2 * a);
printf("root 1 = %.2lf \n",root1);
printf("root 2 = %.2lf \n",root2);
}
else if (discriminant == 0)
{
printf("The real and equal roots are: \n");
root1 = root2 = -b / (2 * a);
printf("root 1 = root 2 = %.2lf", root1);
}
else
{
Assignment No. – II Page - 14 Md Imrajul Alam, 20/CS/002, </> CS Dept, FIEM
Programming for Problem Solving Lab (C)
(ESCS - 291)
CSE – 2nd Sem. – 1st Year
return 0;
}
OUTPUT: