KEMBAR78
14 Program | PDF | Computing | Computer Programming
0% found this document useful (0 votes)
61 views15 pages

14 Program

The document contains code submissions from a student named Saikat Roy for various programming assignments on checking data types and values in C programming. It includes 6 programs to check if a number is positive, negative or zero; divisible by 5 and 11; a leap year; an alphabet, digit or special character; uppercase or lowercase; and the validity of a triangle based on side lengths. For each assignment, the student provides the date it was given, when the code was executed and submitted, screenshots of the code and outputs.

Uploaded by

Saikat Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views15 pages

14 Program

The document contains code submissions from a student named Saikat Roy for various programming assignments on checking data types and values in C programming. It includes 6 programs to check if a number is positive, negative or zero; divisible by 5 and 11; a leap year; an alphabet, digit or special character; uppercase or lowercase; and the validity of a triangle based on side lengths. For each assignment, the student provides the date it was given, when the code was executed and submitted, screenshots of the code and outputs.

Uploaded by

Saikat Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

1

Name :- SAIKAT ROY

Course Name:- BCA

Date of Assignment Given:- 6/11/2022

Date Code Executed: - 16/11/2022

Date Assignment Submitted:- 18/11/2022

Assignment or Program Name:- Write a program in C to check whether a number is negative , positive or
zero.

CODE:- SCREENSHOT OF THE CODE:-


#include <stdio.h>

int main()
{
int num;
printf("Enter any number: ");
scanf("%d", &num);
if(num > 0)
{
printf("Number is POSITIVE");
}
if(num < 0) OUTPUT:
{
printf("Number is NEGATIVE");
}
if(num == 0)
{
printf("Number is ZERO");
}
return 0;
}
Name :- SAIKAT ROY

Course Name:- BCA

Date of Assignment Given:- 6/11/2022

Date Code Executed:- 16/11/2022

Date Assignment Submitted:- 18/11/2022

Assignment or Program Name:- Write a C program to check a number is a divisible by 5 and 11 or not.

CODE:- SCREENSHOT OF THE CODE:-

//C program to check divisibility by 5 and 11.

#include <stdio.h>
int main()
{
int num;
printf("Enter any number: ");
scanf("%d", &num);
if((num % 5 == 0) && (num % 11 == 0))
{
printf("Number is divisible by 5 and 11"); OUTPUT:-
}
else
{
printf("Number is not divisible by 5 and 11");
}
return 0;
}
Name :- SAIKAT ROY

Course Name:- BCA

Date of Assignment Given:- 6/11/2022

Date Code Executed:- 16/11/2022

Date Assignment Submitted:- 18/11/2022

Assignment or Program Name:- Write a program in C to check whether a year is leap year or not.

CODE:-
// C progran to check a year is leap year or not
#include <stdio.h> SCREENSHOT OF THE CODE:-

int main()
{
int year;
printf("Enter a year (YYYY): ");
scanf("%d", &year);
if (year % 4 == 0) {
printf("%d is a leap year.", year);
}
else {
printf("%d is not a leap year.", year);
}
return 0; OUTPUT:-

}
Name :- SAIKAT ROY
Course Name:- BCA

Date of Assignment Given:- 6/11/2022

Date Code Executed:- 16/11/2022

Date Assignment Submitted:- 18/11/2022


Assignment or Program Name:- Write a C program to check whether a character is alphabet or not.

CODE:-
// C program to check whether a charecter is alphabet or not.
Screenshot of the code:-
#include <stdio.h>
int main() {
char c;
printf("Enter a character: ");
scanf("%c", &c);

if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
printf("%c is an alphabet.", c);
else
printf("%c is not an alphabet.", c);

return 0;
} OUTPUT:-
Name :- SAIKAT ROY

Course Name:- BCA

Date of Assignment Given:- /11/2022

Date Code Executed:- 16/11/2022

Date Assignment Submitted:- 18/11/2022

Assignment or Program Name:- Write a C program to check whether an alphabet is vowel or consonant.

CODE:-
// Check whether input any alphabet vowel or consonant
#include <stdio.h>
void main()
{
int x;
printf("Enter any alphabet: ");
scanf("%c", &x);
if(x)
if(x=='a'|| x=='e'|| x=='i'|| x=='o' || x=='u'||x=='A'|| x=='E' || x=='I'|| x=='O' || x=='U')
printf("\nYour alphabet '%c' is vowel.", x);
else
printf("\nYour alphabet '%c' is consonant. ",x);
}
Output:- Screenshot of the code:-
Name :- SAIKAT ROY

Course Name:- BCA

Date of Assignment Given:- /11/2022

Date Code Executed:- 16/11/2022

Date Assignment Submitted:- 18/11/2022

Assignment or Program Name:- Write a C program to input any character and check whether it is alphabet,
digit or special character.

CODE:-
// C program to check alphabet, digit or special character. Screenshot of the code:-
#include <stdio.h>
int main()
{
int ch;
printf("Enter any character: ");
scanf("%c", &ch);
if((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
{
printf("'%c' is alphabet.", ch);
}
else if(ch >= '0' && ch <= '9') Output:-

{
printf("'%c' is digit.", ch);
}
else
{
printf("'%c' is special character.", ch);
}
return 0;
}
Name :- SAIKAT ROY

Course Name:- BCA

Date of Assignment Given:- /11/2022

Date Code Executed:- 16/11/2022

Date Assignment Submitted:- 18/11/2022

Assignment or Program Name:- Write a C program to check whether a character is upper case or lower case
alphabet.

CODE:-
// C program to check whether a character is uppercase or lowercase
#include <stdio.h> Screenshot of the code:-

int main()
{
int ch;
printf("Enter any character: ");
scanf("%c", &ch);
if(ch >= 'A' && ch <= 'Z')
{
printf("'%c' is uppercase alphabet.", ch);
} Output:-
else if(ch >= 'a' && ch <= 'z') Output:-

{
printf("'%c' is lowercase alphabet.", ch);
}
else
{
printf("'%c' is not an alphabet.", ch);
}
return 0; }
Name :- SAIKAT ROY

Course Name:- BCA

Date of Assignment Given:- 6/11/2022

Date Code Executed:- 16/11/2022

Date Assignment Submitted:- 18/11/2022

Assignment or Program Name :- Write a C program to input week number and print of week day.

CODE:-
// Write a C program to input week number and print week day

#include<stdio.h> Screenshot of the code:-

void main()

int n;

printf("Enter any week number(1-7): ");

scanf("%d",&n);

switch(n)

case 1:

printf("\nSunday");

break;

case 2:

printf("\nMonday");

break;

case 3: OUTPUT:-
printf("\nTuesday");

break;

case 4:

printf("\nWednesday");

break;

case 5:

printf("Thursday");

break;

case 6:

printf("\nFriday");

break;

case 7:

printf("\nSaturday");

break;

default:

printf("\nYou have entered wrong value") ; }

}
Name :- SAIKAT ROY

Course Name:- BCA

Date of Assignment Given:- 6/11/2022

Date Code Executed:- 16/11/2022

Date Assignment Submitted:- 18/11/2022

Assignment or Program Name:- Write a C program to input month number and print number of days in that month.

CODE:-
// C program to input month number and print number of days.
#include <stdio.h>
int main ()
{
int N;
printf ("Enter a month number (1-12): ");
scanf ("%d",&N);
if (N == 1 || N == 3 || N == 5 || N == 7 || N == 8 || N == 10 || N == 12)
{
printf("No. of days in that month is 31 Days."); Screenshot of the code:-
}
else if (N == 4 || N == 6
|| N == 9 || N == 11) {
printf("No. of days in that month is 30 Days.");
}
else if (N == 2) {
printf("No. of days in that month is 28 days or\n");
printf("if the year is leap year then it's 29 Days.");
} Output:-

else {
printf("Invalid Month.");
}
}
Name :- SAIKAT ROY

Course Name:- BCA

Date of Assignment Given:- 6/11/2022

Date Code Executed:- 16/11/2022

Date Assignment Submitted:- 18/11/2022

Assignment or Program Name:- Write a C program to input angles of a triangle and check whether triangle is valid or
not.

CODE:-
// Input angles of a triangle and check whether triangle is valid or not.
#include <stdio.h>
Screenshot of the code:-
void main ()
{
int a,b,c;
printf("Enter the first angle of triangle = ");
scanf("%d", &a);
printf("\nEnter the second angle of triangle = ");
scanf("%d", &b);
printf("\nEnter the second angle of triangle = ");
scanf("%d", &c);
if(180==a+b+c)
printf("\nThis is a valid Triangle"); Output:-

else
printf("\n This Triangle is not valid ");
}
Name :- SAIKAT ROY

Course Name:- BCA

Date of Assignment Given:- 6/11/2022

Date Code Executed:- 16/11/2022

Date Assignment Submitted:- 18/11/2022

Assignment or Program Name:- Write a C program to input sides of a triangle and check whether a triangle valid or
not.

CODE:-
// C program to input sides of a triangle and check whether a triangle valid or not.
#include <stdio.h>
int main()
{
int side1, side2, side3;
printf("Enter three sides of triangle: \n");
scanf("%d%d%d", &side1, &side2, &side3);
if (((side1 + side2) > side3) || ((side2 + side3) > side1)||((side1 + side3) > side2))

{ Screenshot of the code:-


printf("The Triangle is Valid");
}
else{
printf("The Triangle is Not Valid");
}
}

Output:-
Name :- SAIKAT ROY

Course Name:- BCA

Date of Assignment Given:- 6/11/2022

Date Code Executed:- 16/11/2022

Date Assignment Submitted:- 18/11/2022

Assignment or Program Name:- Write a C program to check whether a triangle is equilateral ,isosceles or scalene
triangle.

CODE:-
// Check whether the triangle is equilateral, isosceles or scalene triangle.

#include <stdio.h> Screenshot of the code:-


void main ()
{
int a,b,c;
printf("Enter the first side of any Triangle =");
scanf("%d", &a);
printf("\nEnter the second side of any Triangle =");
scanf("%d", &b);
printf("\nEnter the third side of any Triangle =");
scanf("%d", &c);
if(a==c && b==c && a==c)
printf("\nThis triangle is an Equilateral Triangle");

else if(a==b || b==c || a==c ) Output:-


printf("\nThis triangle is an Isosceles Triangle");
else
printf("\nThis triangle is a Scalene Triangle");
}
Name :- SAIKAT ROY

Course Name:- BCA

Date of Assignment Given:- 6/11/2022

Date Code Executed:- 16/11/2022

Date Assignment Submitted:- 18/11/2022

Assignment or Program Name:- Write a C program to input narks if five subjects to calculate their percentage and
grade.

CODE:-
/*C program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer.

Calculate percentage and grade according to following: */

#include <stdio.h>

void main()

{ Screenshot of the code:-


int p,c,b,m,s,t,r;

printf("Marks of Physics =");

scanf("%d", &p);

printf("\nMarks of Chemistry =");

scanf("%d", &c);

printf("\nMarks of Biology =");

scanf("%d", &b);

printf("\nMarks of Mathematics =");

scanf("%d", &m);

printf("\nMarks of Computer =");

scanf("%d", &s);

t= p+c+b+m+s;

printf("\nTotal marks =%d", t);

r= 100*t/500;

printf("\nPercentage =%d", r);

if(r>=90) //Percentage >= 90% : Grade A Output:-


printf("\nGrade ='A'");

else if(r>=80) //Percentage >= 80% : Grade B

printf("\nGrade ='B'");

else if(r>=70) //Percentage >= 70% : Grade C

printf("\nGrade ='C'");

else if(r>=60) //Percentage >= 60% : Grade D

printf("\nGrade ='D'");

else if(r>=40)//Percentage >= 40% : Grade E

printf("\nGrade ='E'");

else //Percentage < 40% : Grade F

printf("\nGrade ='F'");

}
Name :- SAIKAT ROY

Course Name:- BCA

Date of Assignment Given:- 6/11/2022

Date Code Executed:- 16/11/2022

Date Assignment Submitted:- 18/11/2022

Assignment or Program Name:- Write a C program to input basic salary of an employee it’s gross salary.
CODE:-
// C program to input basic salary of an employee and calculate its Gross salary according to following:
#include <stdio.h>
void main ()

{ Screenshot of the code:-


int s,hra,da;
printf("Enter Salary: ");
scanf("%d", &s);
if(s<=10000) //Basic Salary <= 10000 : HRA = 20%, DA = 80%
{
hra = s*20/100;
da = s*80/100;
printf("\nHRA = %d", hra);
printf("\nDA = %d", da);}
else if(s<=20000) //Basic Salary <= 20000 : HRA = 25%, DA = 90%
{

hra = s*25/100; Output:-


da = s*90/100;
printf("\nHRA = %d", hra);
printf("\nDA = %d", da);}
else if(s>20000) //Basic Salary > 20000 : HRA = 30%, DA = 95%
{
hra = s*30/100;
da = s*95/100;
printf("\nHRA = %d", hra);
printf("\nDA = %d", da);}
}

You might also like