C-Record Template
C-Record Template
1A
I/O STATEMENTS
AIM
To write and execute a c program to demonstrate the use of printf() and scanf()
statements to read and print values of variables of different data types.
ALGORITHM
PROGRAM
OUTPUT
RESULT
Thus, the C program to get the number from the user and display it is executed and
verified successfully.
EX.NO.1B
OPERATORS
AIM
To write a C program to perform addition, subtraction, division, multiplication, and
modulo division on two integer numbers.
ALGORITHM
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
int a,b,sum,sub,mul,div;
float mod;
printf(“enter a value:”);
scanf(“%d”,&a);
printf(“enter b value:”);
scanf(“%d”,&b);
sum=a+b;
sub=a-b;
mul=a*b;
div=a/b;
mod=a%b;
printf(“\n addition:%d”,sum);
printf(“\n subtraction:%d”,sub);
getch();
OUTPUT
RESULT
Thus, the C program to perform addition, subtraction, division, integer division,
multiplication, and modulo division on two integer numbers has been executed and the output
is verified successfully
EX.NO.1C
EXPRESSIONS
AIM
To write a C program to perform Relational, logical and conditional expression
ALGORITHM
PROGRAM
#includ<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf(“\n enter a value:”);
scanf(“%d”,&a);
printf(“\n enter b value:”);
scanf(“%d”,&b);
printf(“\n equal to:%d”,(a==b));
printf(“\n not equal to:%d”,(a!=b));
printf(“\n greater than:%d”,(a>b));
printf(“\n lesser than:%d”,(a<b));
printf(“\n lesser than or equal to :%d,(a<=b));
printf(“\n and:%d”,(a==b)&&(a>b));
printf(“\n or:%d”,(a==b)||(a>b);
printf(“\n conditional:%d”,(a==b)?(a>b):(a<b));
getch();
}
OUTPUT
RESULT
Thus, the C program to perform Relational, logical and conditional expression has
been executed and output is verified successfully.
EX.NO.2A
AIM
To write a C program to determine whether a person is eligible to vote using if-else
statement.
ALGORITHM
PROGRAM
OUTPUT
RESULT
Thus, the C program to determine whether a person is eligible to vote using if
statement to has been executed and the output is verified successfully.
EX.NO.2B
CONDITIONAL STATEMENTS (Nested If-Else)
AIM
To write a C Program to display the examination result.
ALGORITHM
PROGRAM
Use Times New Roman 12
OUTPUT
RESULT
Thus, the C Program to display the examination result has been executed and the
output is verified successfully.
EX.NO.2C
LOOPING CONSTRUCTS-(While Loop)
AIM
To write and execute a c program to calculate the sum of numbers from M to N using
while loop.
ALGORITHM
FLOWCHART
PROGRAM
Use Times New Roman 12
OUTPUT
RESULT
Thus, the C program to calculate the sum of numbers from M to N using while loop
has been executed and the output is verified successfully.
EX.NO.2D
LOOPING CONSTRUCTS (Do-While Loop)
AIM
To write and execute a c program to display the square and cube of first N natural
numbers using a do-While loop.
ALGORITHM
FLOWCHART
PROGRAM
Use Times New Roman 12
OUTPUT
RESULT
Thus, the C program to display the square and cube of first N natural numbers using a
do-While loop has been executed and the output is verified successfully.
EX.NO.2E
LOOPING CONSTRUCTS (for Loop)
AIM
To write and execute a C program to print the right-angled triangle pattern using for
loop.
ALGORITHM
FLOWCHART
PROGRAM
Use Times New Roman 12
OUTPUT
RESULT
Thus, the C program to print the pattern using for loop has been executed and the
output is verified successfully.
EX.NO.3A
ARRAYS-One Dimensional Array
AIM
To write a C program to sort the array elements in an ascending order.
ALGORITHM
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20];
clrscr();
int i,j,a;
printf(“ enter 1st element:”);
scanf(“%d”,&a[0]);
printf(“\n enter 2nd element:”);
scanf(“%d”,&a[1]);
printf(“\n enter 3rd element:”);
scanf(“%d”,&a[2]);
for(i=0;i<3;++i)
{
for(j=0;j<3;++j)
{
if(a[i]>a[j])
{
b=a[i];
a[i]=a[j];
a[j]=b;
}
}
}
printf(“the numbers in ascending\n”);
for(i=0;i<3;i++)
{
printf(“%d\n”,a[i]);
}
getch();
}
OUTPUT
RESULT
Thus, the C program to sort the array elements in ascending order is executed and
verified successfully.
EX.NO.3B
ARRAYS-Two-Dimensional Array
AIM
To write a C program to perform matrix multiplication using two-dimensional array.
ALGORITHM
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],mul[3][3],i,j,k;
clrscr();
printf(“enter 1st matrix:”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“enter 2nd matrix:”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++);
{
mul[i][j]=0;
for(k=0;k<3;k++)
{
mul[i][j]+=a[i][k]*b[k][j];
}
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“%d\t”,mul[i][j]);
}
printf(“\n”);
}
getch();
}
OUTPUT
RESULT
Thus, the C program for matrix multiplication using two-dimensional array is
executed and verified successfully.
EX.NO.3C
STRINGS-strcat()
AIM
To write and execute a c program to concatenate two strings.
ALGORITHM
PROGRAM
#include<stdio.h>
#include<conio.h>
Void main()
{
char str1[40];
char str2[40];
clrscr();
printf(“ enter string1:”);
gets(str1);
printf(“ enter string2:”);
gets(str2);
printf(“The string after concatenate:%s”,strcat(str1,str2));
getch();
}
OUTPUT
EX.NO.3D
STRINGS-strcmp()
AIM
To write and execute a c program to compare two strings.
ALGORITHM
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
char str1[15];
char str2[15];
int v;
clrcsr();
printf(“enter the 1st string:”);
gets(str1);
printf(“\n enter the 2nd string:”);
gets(str2);
v=strump(str1,str2);
if(v==0)
{
printf(“\n strings are equal”);
}
else
{
printf(“\n strings are not equal”);
}
getch();
}
OUTPUT
RESULT (handwritten)
Thus, the c program for comparing two strings has been executed and the output is
verified successfully.
EX.NO.3E
STRINGS-strrev()
AIM
To write and execute a C program to reverse the given string
ALGORITHM
PROGRAM
OUTPUT
RESULT
Thus, the c program for reverse a given string has been executed and the output is
verified successfully.
EX.NO.4A
FUNCTIONS
AIM
To write a C program to __________________________using function.
ALGORITHM
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
char a[50];
clrcsr();
printf(“ enter the string:”);
gets(a);
printf(“The reverse of string is:%s”,strrev(a));
getch();
}
OUTPUT
RESULT
Thus, the C program to _________________________________using function has
been executed and the output is verified successfully.
EX.NO.4B
RECURSIVE FUNCTIONS
AIM
To find the Fibonacci Series of a given number using recursive function
ALGORITHM
PROGRAM
#include<stdio.h>
#include<conio.h>
{
if(n==1&&n==0)
{
return n;
}
else
{
return fib(n-1)+fib(n-2);
}
}
void main()
{
int n,i;
clrscr();
printf(“enter a number:”);
scanf(“%d”,&n);
printf(“The Fibonacci series:\n”);
for(i=0;i<n+1;i++)
{
printf(“%d\t”,fib(i));
}
getch();
}
OUTPUT
RESULT
Thus, the C program to find the Fibonacci Series of a given number using recursive
function is compiled and executed successfully.
EX.NO.5
POINTERS
AIM
To find the area of triangle using pointers.
ALGORITHM
PROGRAM
Use Times New Roman 12
OUTPUT
RESULT
Thus, the C program to find the area of triangle using pointers is compiled and
executed successfully.
EX.NO.6
STRUCTURES
AIM
To read and display the information about a student using Structures
ALGORITHM
PROGRAM
#include<stdio.h>
#include<conio.h>
{
struct student
{
int roll;
clrscr();
char name[20];
int mark[3];
int t;
float avg;
}s[3],temp;
int i,j;
printf(“\n enter student info”);
for(i=0;i<3;i++)
{
printf(“\n enter Roll no:”);
scanf(“%d”,&s[i].roll);
printf(“\n enter name:”);
scanf(“\n%s”,&s[i].name);
printf(“\n enter marks”);
for(j=0;j<3;j++)
{
scanf(“%d”,&s[j].mark[j]);
}
s[i].t=s[i].mark1+s[i].mark2+s[i].mark3;
s[i].avg=s[i].t/3;
}
for(i=0;i<3;i++)
{
for(j=i+1;j<3;j++)
{
if(s[i].t<s[i].t)
{
temp=s[i];
s[i]=s[j];
s[j]=temp;
}
}
}
printf(“\n The student info are:”);
printf(“\n ROLL NO\t NAME\t TOTAL\t AVG\t”);
for(i=0;i<3;i++)
{
printf(“\n%d\t %s\t %d\t %f\t”,s[i].roll,s[i].name,s[i].t,s[i].avg);
}
getch();
}
OUTPUT
RESULT
Thus, the C program using structure to read and display the information about a
student has been executed and the output is verified successfully.