Program
Program
THE SCREEN
# include <stdio.h>
# include <conio.h>
void main ( )
{
printf (hello);
getch ( );
}
WRITE A PROGRAM WHICH PRINTS THE
MINIMUM AND MAXIMUM VALUES OF AN
INTEGER
# include <stdio.h>
# include <conio.h>
void main ( )
{
printf (Minimum int = %i \n , INT_MIN);
printf (Maximum int = %i, INT_MAX);
getch ( );
}
WRITE
A
PROGRAM
WHICH
USES
OPERATORS (CALCULATE THE AREA OF A
TRIANGLES, VOLUME OF SPHERE AND
ARRANGE THE RESULTANT VALUES IN
ASCENDING ORDER)
# include <stdio.h>
# include <conio.h>
# include <maths.h>
void main ( )
{
float a, b, c, s, area, d, vol;
printf (Enter triangle side A:);
scanf (%f, &a);
printf (\n Enter triangle side B:);
scanf (%f, &b);
printf (\n Enter triangle side C:);
scanf (%f, &c);
printf (\n Enter diameter of sphere:);
scanf (%f, &d);
s = (a + b + c) / 2;
area = sqrt (s * (s a) * (s b) * (s c));
vol = (3.14 / 6) * (d * d * d);
if (vol > area)
{
printf ( \n Area of triangle = %f, area);
printf ( \n Volume of sphere = %f, vol);
}
else
{
printf ( \n Volume of sphere = %f, vol);
printf ( \n Area of triangle = %f, area);
}
getch ( );
}
WRITE A PROGRAM THAT PRINT A SIMPLE
TRIANGLE OF ASTERISKS
# include <stdio.h>
# include <conio.h>
void main ( )
{
int i, j;
for (i = 1; i < = 10; i++)
{
for (j = 1; j < = I; j++)
{
printf ( * );
}
printf ( \n);
}
getch ( );
}
WRITE
A PROGRAM
TO
PRINT THE
NUMBERS BETWEEN 1 TO 10, ALONG WITH
AN INDICATION OF WHETHER EACH IS EVEN
OR ODD
# include <stdio.h>
# include <conio.h>
void main ( )
{
int i;
for (i = 1; i < = 10; i++)
{
if ( I % 2 == 0)
{
printf (%d is even \n, i);
}
else
{
printf(%d is odd \n, i);
}
}
getch ( );
}
WRITE
A
PROGRAM
TO
GENERATE
MULTIPLICATION TABLE OF NUMBER
USING FOR LOOP
# include <stdio.h>
# include <conio.h>
void main ( )
{
int n, table, i;
printf (Enter Number:);
scanf (%d, &n);
for (i = 1; i < = 10; i++)
{
table = n * i;
printf( \n %d x %d = %d, n, i, table);
}
getch ( );
}
}
printf(\n Factorial of N is : %d, result);
getch ( );
}
return 0;
getch ( );
}
float celsius (int x)
{
float y;
y = 5 * (x 32) / 9;
return y;
}
WRITE
A
PROGRAM
WHICH
USES
MULTIPLE ARGUMENTS IN A FUNCTION
(DEVELOP A USER-DEFINED FUNCTION TO
GENERATE A RECTANGLE). USE THE
FUNCTION FOR PASSING ARGUMENTS TO
DRAW THE FUNCTION FOR PASSING
ARGUMENTS TO DRAW DIFFERENT SIZES
OF RECTANGLES AND SQUARES.
# include <stdio.h>
# include <conio.h>
void box (int length, int width);
int main ( )
{
box (5, 5);
box (5, 10);
box (7, 7);
{
int year;
printf (Enter Year:);
scanf (%d, &year);
if (year % 4 == 0)
{
Printf (Leap Year);
}
else
{
printf(Not Leap Year);
}
getch ( );
}
WRITE A PROGRAM THT INPUT THREE
NUMBERS AND FIND THE LARGEST NUMBER
# include <stdio.h>
# include <conio.h>
void main ( )
{
int n, result = 1, counter = 1;
printf (Enter the value of N:);
scanf (%d, &n);
while (counter < = n)
{
result = counter * result;
counter + = 1;
}
printf(\n Factorial of N is : %d, result);
getch ( );
}
WRITE
A
PROGRAM
TO
ENTER
A
CHARACTER AND FIND WHETHER IT IS
VOWEL OR NOT USING SWITCH STATEMENT.
# include <stdio.h>
# include <conio.h>
void main ( )
{
char ch;
printf (Enter the Character:);
scanf (%c, &ch);
switch (ch)
{
case A:
case a:
printf (Vowel);
break;
case E:
case e:
printf (Vowel);
break;
# include <conio.h>
void main ( )
{
int a, b;
printf (Enter two Numbers:);
scanf (%d %d, &a, &b);
a>b? printf(%d is larger number,
printf(%d is larger number, b);
getch ( );
}
a);
case I:
case i:
printf (Vowel);
break;
case O:
case o:
printf (Vowel);
break;
case U:
case u:
printf (Vowel);
break;
default:
printf (Not Vowel);
break;
}
getch ( );
}
WRITE A PROGRAM THAT INTERCHANGE
VALUES OF TWO VARIABLES BY USING THIRD
VARIABLE.
#include <stdio.h>
#include <conio.h>
int main( )
{
int x, y, temp;
printf("Enter the value of x and y\n");
scanf("%d%d", &x, &y);
printf("Before Swapping\nx = %d\ny =
%d\n",x,y);
temp = x;
x = y;
y = temp;
printf("After Swapping\nx = %d\ny =
%d\n",x,y);
getch ( );
return 0;
}
getch ( );
return 0;
}
}
WRITE A PROGRAM THAT PRINT ALL ODD
NUMBERS LESS THAN 100 SKIPING
THOSE THAT ARE EXACTLY DIVISIBLE BY
7.
#include <stdio.h>
#include <conio.h>
int main( )
{
int i;
for (i = 1; i <= 99; i++)
{
if (i % 7 == 0)
printf (%d \n, i);
}
getch ( );
return 0;
}
WRITE
A
PROGRAM
THAT
READS
TEMPERATURE AND PRINT A DIFFERENT
MESSAGES.
#include <stdio.h>
#include <conio.h>
int main( )
{
int temp;
printf("Enter Temperature:");
scanf (%d, & temp);
if (temp > 35)
printf(It is Hot);
elseif (temp > 20)
printf (Nice Day);
else
printf(It is Cold);
getch ( );
return 0;
}
WRITE A PROGRAM TO
DISTANCE WHERE
S = Vt + at2
#include <stdio.h>
#include <conio.h>
int distance (int v, int t, int a);
int main( )
{
int b, c, d;
printf("Enter the value of V:");
scanf (%d, &b);
printf("Enter the value of t:");
scanf (%d, &c);
printf("Enter the value of a:");
scanf (%d, &d);
distance (b, c, d);
getch ( );
return 0;
}
int distance (int v, int t, int a)
FIND
THE
d = m/v;
printf (Density of Cylinder = %d, d);
}
{
int S;
S = v*t + a*t*t;
printf (Distance = %d, S);
}
WRITE A PROGRAM TO GET A NUMBER
AND FIND ITS SQUARE AND FUNCTION
ALSO RETURN A VALUE.
#include <stdio.h>
#include <conio.h>
int square (int a);
int main( )
{
int b, Sq;
printf("Enter the Number:");
scanf (%d, &b);
Sq = square (b);
printf (Square of Given Number:%d, Sq);
getch ( );
return 0;
}
int square (int a)
{
int S;
S = a * a;
return (S);
}
return 0;
}
if ( c == i )
{
printf("%d\n",i);
count++;
}
i++;
}
getch ( );
return 0;
}
WRITE A PROGRAM THAT PRINT ASCII
CHARACTER FOR ENTERED VALUE
#include <stdio.h>
# include <conio.h>
int main( )
{
int var1;
printf (Enter value:);
scanf (%d, &var1);
printf("\n Character of ASCII value: %c",
var1);
getch ( );
return 0;
}
WRITE
A
PROGRAM
TO
DISPLAY
CHARACTER FROM A TO Z USING LOOPS
EITHER IN UPPERCASE OR LOWERCASE
DEPENDING UPON THE DATA FROM USER
#include <stdio.h>
#include <conio.h>
int main( )
{
char c;
printf("Enter u to display characters in
uppercase and l to display in lowercase: ");
scanf("%c", &c);
if(c=='U' || c=='u')
{
for(c='A'; c<='Z'; ++c)
printf("%c", c);
}
if (c=='L' || c=='l')
{
for(c='a'; c<='z'; ++c)
printf("%c", c);
}
if (c!='U' || c!='L' || c=='u' || c=='l')
printf("Error !!!");
getch ( );
return 0;
}
WRITE A PROGRAM THAT PRINT ALL
A NUMBER
#include <stdio.h>
#include <conio.h>
int main( )
{
int n, count=0;
printf ("Enter an integer: ");
scanf ("%d", &n);
while (n!=0)
{
n / = 10;
/* n=n/10 */
++count;
}
printf ("Number of digits: %d", count);
getch ( );
return 0;
}
WRITE PROGRAM TO FIND GROSS SALARY OF
A PERSON
#include <stdio.h>
#include <conio.h>
int main( )
{
int gross, salary, basic, da, ta;
printf ("Enter basic salary : ");
scanf ("%d", &basic);
ASCII CHARACTER
#include <stdio.h>
#include <conio.h>
int main( )
{
int i;
for(i=0;i<=255;i++)
printf("ASCII value of character %c: %d\n", i,
i);
getch ( );
return 0;
}
WRITE
A
PROGRAM
TO
COMPUTE
REMAINDER AND QUOTIENT
#include <stdio.h>
#include <conio.h>
int main( )
{
int dividend, divisor, quotient, remainder;
printf ("Enter dividend: ");
scanf ("%d", ÷nd);
printf ("Enter divisor: ");
scanf ("%d", &divisor);
quotient = dividend / divisor;
remainder = dividend % divisor;
printf ("Quotient = %d\n", quotient);
printf ("Remainder = %d", remainder);
getch ( );
return 0;
}
while (k != 2 * i-1)
{
printf ("*");
K++;
}
k=0;
printf("\n");
}
getch ( );
return 0;
}