INDEX
Staff
Ex.No Date Title of the Program Page Signature
1.
Arithmetic Operations
2.
Odd or Even
3.
Factorial
4.
Print the Message
5.
Biggest among Three nos
6.
Multiplication Table
7.
Prime or Not
8. Ascending ,Decending
Order
9.
Simple Interest
10. Positive Negative
Number
11.
Sum of the digits
12.
String Manupulation
13. Reverse the Integer
number
14.
Student Details
15. Factorial Using
Recursion
EX NO : 1 ARITHMETIC OPERATION
DATE :
AIM:
To write a C program to perform Arithmetic Operation.
CODING:
#include<stdio.h>
#include<conio.h
> void main()
{
int a = 8,b = 4, c,d,e,f;
clrscr();
c=a+b;
printf("a+b = %d \n",c);
d=a-b;
printf("a-b = %d \n",d);
e=a*b;
printf("a*b = %d \n",e);
f=a/b;
printf("a/b = %d \n",f);
getch();
}
RESULT:
Thus the program was successfully executed and the output is
verified.
OUTPUT:
a+b= 12
a-b=4
a*b=32
a/b=2
EX NO : 2 ODD OR EVEN
DATE :
AIM:
To write a C program to check the number is odd or even.
CODING:
#include <stdio.h>
#include<conio.h
> void main()
{
int num;
clrscr();
printf("
Enter an
integer:
");
scanf("%d", &num);
if(num %2 == 0)
printf("%d is
even.", num);
else
printf("%d is odd.", num);
getch();
}
RESULT:
Thus the program was successfully executed and the output is
verified.
OUTPUT:
Enter an integer: 15
15 is odd
Enter an integer: 6
6 is even
EX NO : 3 FACTORIAL
DATE :
AIM:
To write a C program to calculate Factorial Number.
CODING:
#include <stdio.h>
#include<conio.h
> void main()
{
int n, i,f;
f = 1;
clrscr();
printf("Enter an integer: ");
scanf("%d", &n);
for (i = 1; i <= n; ++i)
{
f *= i;
}
printf("Factorial of %d = %d", n,f);
getch();
}
RESULT:
Thus the program was successfully executed and the output is
verified
OUTPUT:
Enter an integer: 5
Factorial of 5= 120
EX NO : 4 PRINT THE MESSAGE
DATE :
AIM:
To write a C program to Print The Message.
CODING:
#include <stdio.h>
#include <conio.h>
void main()
{
printf("Hello…. World!");
printf(“Good Morning”);
getch();
}
RESULT:
Thus the program was successfully executed and the output is
verified.
OUTPUT:
Hello…..World!
GoodMorning
EX NO : 5 BIGGEST NUMBER
DATE :
AIM:
To write a C program to find the Biggest Number.
CODING:
#include <stdio.h>
#include <conio.h>
void main()
{
int n1, n2, n3;
clrscr();
printf("Enter
three
numbers: ");
scanf("%d%d %d", &n1, &n2, &n3);
if (n1 >= n2 && n1 >= n3)
printf("%d is the largest number.", n1);
else if (n2 >= n1 && n2 >= n3)
printf("%d is the largest number.",
n2);
else
printf("%d is the largest number.", n3);
getch();
}
RESULT:
Thus the program was successfully executed and the output is
verified.
OUTPUT:-
Enter three numbers: 9 4 10
10 is the largest number
EX NO : 6 MULTIPLICATION TABLE
DATE :
AIM:
To write a C program to print Multiplication Table .
CODING:
#include <stdio.h>
#include <conio.h>
void main()
{
int n, i;
clrscr();
printf("
Enter
an
integer:
");
scanf("
%d",
&n);
for (i =
1; i <=
10; +
+i)
{
print
f("%
d*
%d =
%d \
n", n,
RESULT:
i, n *
i);
Thus
}
the program was successfully executed and the output is
verified.
getch();
}
OUTPUT:
Enter an integer: 4
4*1=4
4*2=8
4*3=12
4*4=16
4*5=20
4*6=24
4*7=28
4*8=32
4*9=36
4*10=40
EX NO : 7 PRIME NUMBER
DATE :
AIM:
To write a C program to find the given number is Positive or
Negative
CODING:
#include
<stdio.h> #include
<conio.h> void
main()
{
int n, i, flag =
0;
printf("Enter a positive integer:
"); scanf("%d", &n);
for (i = 2; i <= n / 2; ++i)
{
if (n % i == 0)
{
flag
= 1;
break;
}}
if (n == 1)
{
printf("
1 is
neither
prime nor
composite.
");
}
else
{
if (flag
== 0)
printf("%d is a prime number.", n);
else
printf("%d is not a prime
number.", n);
}
getch();}
OUTPUT:
Enter an Positive integer: 7
7 is a prime number
Enter an positive integer: 15
15 is not a prime nmber
EX NO : 8 ASCENDING & DESCENDING
DATE :
AIM:
To write a C program to ordered Ascending & Descending
CODING:
#include <stdio.h>
#include <conio.h>
void main()
{
int n, data[100], i, j, temp;
clrscr();
printf("How many nos do
You get:");
scanf("%d", &n);
printf(“Enter the nos:”);
for (i = 0; i < n; i++)
scanf("%d", &data[i]);
for (i = 0; i < n-1; i++)
{
for (j = i + 1; j <
n; j++)
{
if (data[i] >
data[j])
{
temp =
data[i]; data[i]
= data[j];
data[j] = temp;
} }}
printf("Ascending
Order:\n"); for (i = 0; i < n;
i++)
printf("%d\n", data[i]);
printf("\nDescending Order:\n");
for (i = n-1; i >= 0; i--)
printf("%d\n",
data[i]);
getch();
}
RESULT:
Thus the program was
OUTPUT:
How many nos do You get: 5
Enter the nos :
10
5
7
12
4
Ascending Order:
4
5
7
10
12
Decending Order:
12
10
7
5
4
EX NO : 9 SIMPLE INTEREST
DATE :
AIM:
To write a C program to find Simple Interest
CODING:
#include<stdio.h>
#include<conio.h
>
#include<math.h>
void main()
{
float p,q,r,SI;
int n;
clrscr();
printf("Enter the value of Principle p = ");
scanf("%f",&p);
printf("Enter the value of Rate r r= ");
scanf("%f",&r);
printf("Enter the Period in year n = ");
scanf("%d",&n);
SI = ((p*r*n)/100);
printf("Simple Interest SI=%f \n",SI);
getch();
}
RESULT:
Thus the program was successfully executed and the output is
verified.
OUTPUT:
Enter the value of Principle p= 1200
Enter the value of rate r= 5.4
Enter the period in Year n=2
Simple Interest SI= 129.600006
EX NO : 10 POSITIVE OR NEGATIVE
DATE :
AIM:
To write a C program to find the given number is Positive or
Negative
CODING:
#include
<stdio.h> #include
<conio.h> void
main()
{
Int
num;
clrscr();
printf(
"Enter a
number:
");
scanf("%d",
&num); if (num
>=0)
{
printf("%d is a positive number.",num);
else
printf("%d is the negative
number.",num));
}
getch();
}
RESULT:
Thus the program was successfully executed and the output is
verified.
OUTPUT:-
Enter a number : 12
12 is a positive number
Enter a number -4
-4 is a negative number
EX NO : 11 SUM OF DIGIT
DATE :
AIM:
To write a C program to calculate the number is Sum Of Digits
CODING:
#include <stdio.h>
#include <conio.h>
void main()
{
int n, t, sum = 0, remainder;
clrscr();
printf("Enter an integer\n");
scanf("%d", &n);
t = n;
while (t != 0)
{
remainder = t
% 10;
sum = sum +
remainder; t =
t / 10;
}
printf("Sum of digits of %d = %d\n", n, sum);
getch();
}
RESULT:
Thus the program was successfully executed and the output is
verified.
OUTPUT:-
Enter an integer n: 346
Sum of digits of 346= 13
EX NO : 12 STRING MANIPULATION
DATE :
AIM:
To write a C program to manipulate String Functions.
CODING:
#include<stdio.h>
#include<conio.h>
#include<string.h
> void main()
{
char
str1[20]="THALA
THALAPATHY";
char str2[20]="THALA";
clrscr();
printf("Length of String=
%d",strlen(str1));
if(strcmp(str1,str2)==0)
{
printf("equal");
}
else
{
printf("Not equal");
}
strcat(str1,str2);
printf("output string=%s",str1);
strcpy(str1,str2);
printf("string str1 is :
%s",str1);
getch();
RESULT:
}
Thus the program was successfully executed and the output is
verified.
OUTPUT:-
Length of String = 15
Not equal
Output string= THALAPATHYTHALA
String str1 is :THALA
EX NO : 13 REVERSE NUMBER
DATE :
AIM:
To write a C program to perform Reverse Number.
CODING:
#include <stdio.h>
#include <conio.h>
void main()
{
int n, rev = 0, remainder;
clrscr();
printf("Enter an integer:
");
scanf("%d",
&n); while (n !=
0)
{
remainder =
n % 10;
rev = rev * 10 +
remainder; n /= 10;
}
printf("Reversed number = %d",
rev); getch();
}
RESULT:
Thus the program was successfully executed and the output is
verified.
OUTPUT:-
Enter an integer: 785
Reversed number= 587
EX NO : 14 STUDENT MARK LIST
DATE :
AIM:
To write a C program to perform Student Mark List using
Structure.
CODING:
#include
<stdio.h> #include
<conio.h> struct
student
{
char
name[50]; int
roll;
float marks;
} s;
void main()
{
printf("Enter information:\
n"); printf("Enter name: ");
clrscr();
fgets(s.name, sizeof(s.name),
stdin);
printf("Enter roll number:
"); scanf("%d", &s.roll);
printf("Enter marks: ");
scanf("%f", &s.marks);
printf("Displaying Information:\
n"); printf("Name: ");
printf("%s", s.name);
printf("Roll number: %d\n",
s.roll); printf("Marks: %.1f\n",
s.marks);
getch();
}
RESULT:
Thus the program was
successfully executed and the
OUTPUT:-
Enter information:
Enter name: Kala
Enter roll number: 001
Enter marks: 85
Displaying Information:
Name : Kala
Rollnumber: 001
Marks: 85
EX NO : 15 FACTORIAL NUMBER USING
RECURSION
DATE :
AIM:
To write a C program to find the Factorila Value using Recursion
CODING:
#include<stdio.h>
#include<conio.h
> int fact(int);
void main()
{
int n,f;
clrscr();
printf("Enter a positive integer: ");
scanf("%d",&n);
f=fact(n);
printf("Factorial of %d = %d\n", n,f);
getch();
}
int fact(int n)
{
int i,f=1;
clrscr();
for(i=1;i
<=n;i+
+)
{
f=f*i;
}
return f;
}
RESULT:
Thus the program was successfully executed and the output is
verified.
OUTPUT:-
Enter a Positive integer: 6
Factorial of 6= 720