0% found this document useful (0 votes)
2 views7 pages

C Programming Assignment

The document contains a C programming assignment with three tasks: checking if a number is even or odd, determining if a number is positive or negative, and associating numbers with colors. Each task is accompanied by sample code demonstrating the implementation in C. The assignment is for a student named T. BH Aradwaj, Roll No 56, from BBA IT 1st Year.

Uploaded by

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

C Programming Assignment

The document contains a C programming assignment with three tasks: checking if a number is even or odd, determining if a number is positive or negative, and associating numbers with colors. Each task is accompanied by sample code demonstrating the implementation in C. The assignment is for a student named T. BH Aradwaj, Roll No 56, from BBA IT 1st Year.

Uploaded by

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

C programming

Assignment

T.BH
ARADWAJ
ROLL NO 56
BBA IT 1ST YEAR
C programming
assignment

1. To check wether the given number is


even or odd
The code for the above programm
#include <stdio.h>
#include <stdlib.h>

int main()
{ int num;
printf ("enter an integer:");
scanf("%d",&num);
if (num%2==0)
printf ("%d is a even",num);
else
{printf("%d is a odd",num);}
return 0;

}
2.to check wether the given number
is positive or negative

The code for the above programm

#include <stdio.h>
1
#include <stdlib.h>

1
int main()
{
double num;
printf("Enter a number: ");
scanf("%lf", &num);
if (num <= 0.0) {
if (num == 0.0)
printf("You entered 0.");
else
printf("You entered a negative number.");
} else
printf("You entered a positive number.");
return 0;
}

3.numbers and colours


#include <stdio.h>
#include <conio.h>

int main()
{ int num;
("cls");
printf ("enter an integer:");
scanf("%d",&num);
if (num==1)
printf ("VOILET");
else
if (num==2)
printf("INDIGO");
else
if (num==3)
printf("BLUE");
else
if (num==4)
printf("GREEN");
else
if (num==5)
printf("YELLOW");
else
if (num==6)
printf("ORANGE");
else
if (num==7)
printf("RED");
return 0;
}

You might also like