Practical File
Practical File
Practical File
PRACTICAL FILE
of
COMPUTER PROGRAMMING - II
BACHELOR OF TECHNOLOGY
(Computer Science Engineering)
Submitted by
20STUCHPN01004
Batch(2020-2024)
Under guidance of
...............................................................................................
INDEX for Practical list
Sr. No. Practical Name Date of Teacher
Practical Signature
1. Write a C program to print “My name”. 09-april-2021
2. Write a C program to print “Welcome to 09-april-2021
the ICFAI UNIVERSITY HP”.
3. Write a C program to add two numbers. 16-april-2021
4. Write a C program to add three numbers. 16-april-2021
5. Write a C program to find square of a 16-april-2021
number.
6. Write a C program to find the cube of a 23-april-2021
number.
7. By using C, do arithmetic operations. 23-april-2021
8. To print the lines on a console without 23-april-2021
entering in printf function.
9. Write a C program to find average of two 30-april-2021
numbers.
10. Write a C program to find average of four 30-april-2021
numbers.
11. Write a C program to find the simple 30-april-2021
interest with the value enter at the time
of program execution.
12. Write a program for char , int and float. 07-may-2021
13. Write a program to find the area of a 07-may-2021
rectangle.
14. Write a program to find the increment 07-may-2021
and decrement operators and also find
(post & pre) operators in case of
increment and decrement operators.
15. Write a program to define the Relational 14-may-2021
operators.
16. Write a program to define the Bitwise 14-may-2021
operators.
17. Write a program to define the Logical 14-may-2021
operators.
18. Write a program to define the Assignment 21-may-2021
operators.
19. Write a program for decision making ‘if’ 21-may-2021
statement.
20. Write a program for decision making ‘if- 21-may-2021
else’ statement.
21. Write a program for decision making ‘if- 28-may-2021
else if ladder’ statement.
22. Write a program for decision making 28-may-2021
‘Switch’ statement.
23. Write any two programs using do- 28-may-2021
while loop statement.
24. Write any two programs while loop 04-june-2021
statement.
25. Write any two programs for loop 04-june-2021
statement.
26. Write any two programs based on type 04-june-2021
conversion/casting.
27. Write any four programs based on storage 11-june-2021
classes.
28. Write any four programs based on 11-june-2021
jumping classes.
29. Write any one program for reverse of a 11-june-2021
number.
30. Write any one program for each 18-june-2021
formatted/unformatted I/O function.
31. Write any one program for each program 18-june-2021
for string function.
32. Write program for function in c. 18-june-2021
33. Write program for function parameters in 25-june-2021
c.
34. Write a program for arrays in c. 25-june-2021
35. Write program for structure in c. 25-june-2021
36. Write program for union in c. 02-july-2021
37. Write program for pointer in c. 02-july-2021
38. Write program for declaration and 02-july-2021
initialization of a variable in c.
39. Write program for to get a number as 09-july-2021
age and display whether the person is
young
or adult in c.
40. Write program to check the given 09-july-2021
character is a vowel or consonant.
41. Write program to reverse the array. 09-july-2021
42. Write program to calculate the factorial 16-july-2021
of a given integer using function.
43. Write a program find the number is 16-july-2021
palindrome or not.
44. Write a program to read n numbers 16-july-2021
into an array A to find the
***Sum of odd numbers.
***Sum of even numbers.
***Average of all numbers.
45. Write a program dynamic 23-july-2021
memory allocation in c.
46. Write a program for file handling in c. 23-july-2021
Practical 1
AIM:- Write a C program to print "Welcome to ICFAI UNIVERSITY HP".
Input Code:-
#include <stdio.h>
int main()
return 0;
OUTPUT:-
Practical 2
AIM:- Write a C program to print "My
#include<stdio.h>
int main()
{
return 0;
OUTPUT:-
Practical 3
AIM:- Write a C program to add two numbers.
INPUT CODE:-
#include<stdio.h>
int main()
int a,b,c;
scanf("%d",&a);
scanf("%d",&b);
c=a+b;
return 0;
OUPUT:-
Practical 4
AIM:- Write a C program to add three numbers.
INPUT CODE:-
#include<stdio.h>
int main()
int a,b,c,d;
scanf("%d",&a);
scanf("%d",&b);
printf("Enter the value of c:");
scanf("%d",&c);
d=a+b+c;
return 0;
OUTPUT:-
Practical 5
AIM:- Write a C program to find the square of a number.
INPUT CODE:-
#include<stdio.h>
int main()
int a;
scanf("%d",&a);
printf("The square of 'a' is:%d\n",a*a);
return 0;
OUTPUT:-
Practical 6
AIM:- Write a C program to find cube of a number.
INPUT CODE:-
#include<stdio.h>
int main()
int a;
scanf("%d",&a);
return 0;
}
OUTPUT:-
Practical 7
AIM:- Write a C program to do operations like multiplication,division,subtraction of two number.
INPUT CODE:-
#include<stdio.h>
int main()
int a,b,c,d;
float e;
scanf("%d",&a);
scanf("%d",&b);
c=a-b;
d=a*b;
e=a/b;
return 0;
Output:-
Practical 8
AIM:- Write a C program to print lines on a console without entering 'printf' function.
INPUT CODE:-
#include<stdio.h>
int main()
University.";
char c[]="In B Tech CSE.";
printf("%s\n%s\n%s\n",a,b,c);
return 0;
OUTPUT:-
Practical 9
AIM:- Write a C program to find the average of two numbers.
INPUT CODE:-
#include<stdio.h>
int main()
float a,b,c;
scanf("%f",&a);
printf("Enter the value of b:");
scanf("%f",&b);
c=(a+b)/2;
return 0;
OUTPUT:-
Practical 10
AIM:- Write a C program to find the average of four numbers.
INPUT CODE:-
#include<stdio.h>
int main()
float a,b,c,d,e;
printf("Enter the value of a:");
scanf("%f",&a);
scanf("%f",&b);
scanf("%f",&c);
scanf("%f",&d);
e=(a+b+c+d)/4;
return 0;
OUTPUT:-
Practical 11
AIM:- Write a C program to find the simple interest.
INPUT CODE:-
#include<stdio.h>
int main()
float p,r,t,SI;
scanf("%f",&p);
scanf("%f",&r);
scanf("%f",&t);
SI=(p*r*t)/100;
printf("SI is %f\n",SI);
return 0;
OUTPUT:-
Practical 12
AIM:- Write a C program for char ,int and float.
INPUT CODE:-
#include<stdio.h>
int main()
int a;
char b[]="Manish";
float c,d;
scanf("%d",&a);
scanf("%f",&c);
d=a*c;
return 0;
OUTPUT:-
Practical 13
AIM:- Write a C program to find the area of
#include<stdio.h>
int main()
float l,b,area;
printf("Length of a rectangle:");
scanf("%f",&l);
printf("Breadth of a rectangle:");
scanf("%f",&b);
area=l*b;
return 0;
}
OUTPUT:-
Practical 14
AIM:- Write a C program to find the increment and decrement operators alse find (post & pre) operators
in case of increment and decrement operators.
INPUT CODE:-
#include<stdio.h>
int main()
int a,b;
scanf("%d",&a);
scanf("%d",&b);
return 0;
OUTPUT:-
Practical 15
AIM:- Write a C program to define the relational operators.
INPUT CODE:-
#include<stdio.h>
int main()
{
int a,b;
scanf("%d",&a);
scanf("%d",&b);
return 0;
OUTPUT:-
Practical 16
AIM:- Write a C program to define the bitwise operators.
INPUT CODE:-
#include<stdio.h>
int main()
int a,b;
scanf("%d",&a);
scanf("%d",&b);
OUTPUT:-
Practical 17
AIM:- Write a C program to define the logical operators.
INPUT CODE:-
#include <stdio.h>
int main()
int a,b;
scanf("%d",&a);
scanf("%d",&b);
if((a>5)&&(b<5)){
if ((a>=10)||(b>=10)){
} if(!
((a>5)&&(b<5))){
// If ((a>5) && (b<5))is true, logical NOT operator will makes it false and vice versa.
return 0;
OUTPUT:-
Practical 18
AIM:- Write a C program to define the assignment operators.
INPUT CODE:-
#include <stdio.h>
int main()
int a=10,b=16;
b+=a;
b-=a;
b*=a;
%=a;
printf("The modulus AND assignment is %d\n",b);
return 0;
OUTPUT:-
Practical 19
AIM:- Write a C program for decision making 'if'
#include <stdio.h>
int main()
int a=441,b=7;
if(a%b==0){
}
return 0;
OUTPUT:-
Practical 20
INPUT CODE:-
#include <stdio.h>
int main()
int a,b;
scanf("%d",&a);
if(a>b){
else if(a==b){
else {
return 0;
OUTPUT:-
AIM20.2:- Write a C program to find the year you entered is leap or not using 'if-else' statement.
INPUT CODE:-
#include <stdio.h>
int main()
int x;
printf("Enter a year:
if (x % 400 == 0) {
else if (x % 100 == 0) {
else if (x % 4 == 0) {
else {
return 0;
OUTPUT:-
Practical 21
AIM21.1:- Write a C program to find the greatest between three numbers using 'if-else' ladder.
INPUT CODE:-
#include <stdio.h>
int main()
int a,b,c;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
if(a>b&&a>c){
printf("a is the greatest number.");
else if(b>a&&b>c){
else{
return 0;
OUTPUT:-
Practical 21
AIM21.1:- Write a C program to show the name of the day in a week using 'if-else' ladder.
INPUT CODE:-
#include <stdio.h>
int main()
int x;
scanf("%d",&x);
if(x==1){
printf("MONDAY\n");
else if(x==2){
printf("TUESDAY\n");
else if(x==3){
printf("WEDNESDAY\n");
else if(x==4){
printf("THRUSDAY\n");
else if(x==5){
printf("FRIDAY\n");
else if(x==6){
printf("SATURDAY\n");
else{
printf("SUNDAY\n");
}
return 0;
OUTPUT:-
INPUT CODE:-
#include<stdio.h>
int main()
int a;
printf("Enter a:");
scanf("%d",&a);
if(a%2==0){
}
else{
return 0;
OUTPUT:-
INPUT CODE:-
#include<stdio.h>
int main()
int a;
printf("Enter a:");
scanf("%d",&a);
if(a>=0){
else{
return 0;
Practical 22
AIM22.1:- Write a C program to to apply operation on two number using switch statement.
INPUT CODE:-
#include <stdio.h>
int main()
int a,b,d;
char operations;
printf("Enter a:");
scanf("%d",&a);
printf("Enter b:");
scanf("%d",&b);
printf("Operation to perform:");
scanf(" %c",&operations);
switch(operations)
case'+':
d=a+b;
break;
case'-':
d=a-b;
break;
case'*':
d=a*b;
break;
case'%':
d=a%b;
break;
default:
return 0;
OUTPUT:-
AIM22.2:- Write a C program to to find the day in a week using switch statement.
INPUT CODE:-
#include <stdio.h>
int main()
{
int Weekday;
printf("Enter Weekday:");
scanf("%d",&Weekday);
switch(Weekday)
case 1:
printf("MONDAY");
break;
case 2:
printf("TUESDAY");
break;
case 3:
printf("WEDNESDAY");
break;
case 4:
printf("THRUSDAY");
break;
case 5:
printf("FRIDAY");
break;
case 6:
printf("SATURDAY");
break;
case 7:
printf("SUNDAY");
break;
default:
return 0;
OUTPUT:-
Practical 23
AIM23.1:- Write a C program, using do while loop print the multiplication table of any number.
INPUT CODE:-
#include <stdio.h>
int main()
int n;
scanf("%d",&n);
int i=1;
do{
printf("%d*%d=%d\n",n,i,n*i);
i++;
}while(i<=10);
return 0;
OUTPUT:-
AIM23.2:- Write a C program, using do while loop print the multiplication table of any number.
INPUT CODE:-
#include <stdio.h>
int main()
int n;
scanf("%d",&n);
int i=1;
do{
printf("%d ",i);
i++;
}while(i<=n);
return 0;
OUTPUT:-
Practical 24
AIM24.1:- Write a C program, using while print the multiplication table of any number.
INPUT CODE:-
#include <stdio.h>
int main()
int n;
scanf("%d",&n);
int i=1;
while(i<=10){
printf("%d*%d=%d\n",n,i,n*i);
i++;
return 0;
OUTPUT:-
AIM24.2:- Write a C program, using while loop print all the numbers from 0 to 200.
INPUT CODE:-
#include <stdio.h>
int main()
int i=0;
while(i<=200){
printf("%d ",i);
i++;
return 0;
}
OUTPUT:-
Practical 25
AIM25.1:- Write a C program, using for loop find the factorial of any number.
INPUT CODE:-
#include <stdio.h>
int main()
int n,a=1,i=1;
printf("Enter n:");
scanf("%d",&n);
for(;i<=n;i++){
a*=i;
return 0;
}
OUTPUT:-
AIM25.2:- Write a C program, using for loop print the infinite no. of lines .
INPUT CODE:-
#include <stdio.h>
int main()
int n;
for(int i=1;i<=n;){
return 0;
OUTPUT:-
AIM25.3:- Write a C program to find the nth number in a fibonacci series.
INPUT CODE:-
#include <stdio.h>
int main()
int n;
printf("Enter n:");
scanf("%d",&n);
int a=0,b=1,c;
for(int i=1;i<=n-2;i++){
c=a+b;
a=b;
b=c;
}
printf("The %dth fibonacci number is : %d ",n,c);
return 0;
OUTPUT:-
AIM25.4:- Write a C program to check whether the entered number is Armstrong number or not.
INPUT CODE:-
#include <stdio.h>
int main() {
int n,x,r,result=0;
scanf("%d",&n);
x=n;
while (x!=0){
r=x%10;
result+=r*r*r;
x/=10;
if (result==n)
else
return 0;
OUTPUT:-
Practical 26
Aim26.1: To make use of implicit type
#include <stdio.h>
int main(void){
int i = 5;
float k = ch + i;
printf("%f", k);
return 0;
OUTPUT:-
INPUT CODE:-
#include <stdio.h>
int main(void){
int k;
k=(int)num;
printf("%d", k);
return 0;
OUTPUT:-
Practical 27
AIM 27: Write any four programs based on storage
INPUT CODE:-
#include <stdio.h>
int main(void){
int k = 10;
printf("%d",k);
return 0;
OUTPUT:-
AIM 27.2 : Write a program for Extern storage
#include <stdio.h>
int main()
int num1 = 3;
int num2 = 4;
return 0;
OUTPUT:-
AIM 27.3 : Write a program for static storage
#include <stdio.h>
int main()
static int k;
static float f;
printf("%d,%c,%f",k,ch,f);
return 0;
OUTPUT:-
AIM 27.4 : Write a program for register storage class.
INPUT CODE:-
#include <stdio.h>
int main()
register int k;
printf("%d",k);
OUTPUT:-
Practical 28
AIM 28: Write any four programs based on jumping classes.
INPUT CODE:-
#include <stdio.h>
int main()
{ printf("K =
%d\n",k); if(k>=8){
break;
OUTPUT:-
AIM 28.2 : Write a program for CONTINUE jumping
#include <stdio.h>
int main() {
int i, j;
{ if (j == 2)
continue;
printf("%d\n", j);
return 0;
OUTPUT:-
AIM 28.3 : Write a program for go-to jumping class.
INPUT CODE:-
#include <stdio.h>
int main() {
int i, j;
{ if (i == 2)
goto there;
printf("%d\n", i);
there:
printf("Two");
return 0;
OUTPUT:-
Practical 29
AIM 29 : Write any one program for reverse of a number.
INPUT CODE:-
#include <stdio.h>
int main()
int n, r = 0;
scanf("%d", &n);
while (n != 0) {
r = r * 10;
r = r + n%10;
n = n/10;
return 0;
}
OUTPUT:-
Practical 30
AIM 30: Write any one program for each formatted /unformatted I/O fxn.
INPUT CODE:-
#include <stdio.h>
int main()
int k;
printf("Enter k : ");
scanf("%d",&k);
printf("k = %d",k);
return 0;
OUTPUT:-
AIM 30.2 : Write a program for unformatted I/O fxn.
INPUT CODE:-
#include<stdio.h>
void main()
char c;
c=getchar();
printf("c = %c ",c);
return 0;
OUTPUT:-
Practical 31
AIM 31: Write any one program for each program for string function.
INPUT CODE:-
#include<stdio.h>
void main()
char ch[10]={'M','a','n','i','s','h','\0'};
return 0;
OUTPUT:-
AIM 31.2 : Write a program for find the length of string.
INNPUT CODE:-
#include<stdio.h>
#include<string.h>
void main()
char ch[10]={'M','a','n','i','s','h','\0'};
return 0;
OUTPUT:-
AIM 31.3 : Write a program for copy of two string.
INPUT CODE:-
#include<stdio.h>
#include<string.h>
void main()
char ch[10]={'M','a','n','i','s','h','\0'};
char ch1[10];
strcpy(ch1,ch);
return 0;
OUTPUT:-
AIM 31.4 : Write a program for find the concatenation of string.
INPUT CODE:-
#include<stdio.h>
#include<string.h>
void main()
char ch[10]={'M','a','n','i','s','h','\0'};
char ch1[20]={'Y','a','d','a','v','\0'};
strcat(ch,ch1);
printf("string is : %s",ch);
return 0;
OUTPUT:-
AIM 31.5 : Write a program for find the reverse of string.
INPUT CODE:-
#include<stdio.h>
#include<string.h>
void main()
char ch[20];
gets(ch);
return 0;
OUTPUT:-
AIM 31.6 : Write a program for comparing the two strings.
INPUT CODE:-
#include<stdio.h>
#include<string.h>
void main()
char ch1[20];
char ch2[20];
gets(ch1);
gets(ch2); if(strcmp(ch1,ch2)==0)
else{
return 0;
OUTPUT:-
INPUT CODE:-
#include<stdio.h>
#include<string.h>
void main()
char ch[20];
gets(ch);
return 0;
OUTPUT:-
AIM 31.8 : Write a program for upper case of a string.
INPUT CODE:-
#include<stdio.h>
#include<string.h>
void main()
char ch[20];
gets(ch);
return 0;
OUTPUT:-
Practical 32
AIM 32: Write program for function in c.
INPUT CODE :-
#include<stdio.h>
int main( )
float m, n ;
n = square ( m );
{
float p;
p = x*x;
return (p);
OUTPUT:-
Practical 33
AIM 33: Write program for function parameters in c.
INPUT CODE:-
#include <stdio.h>
int main()
int n=10;
return 0;
}
int sqr(int p)
p = p*p;
return(p);
OUTPUT:-
INPUT CODE:-
#include <stdio.h>
int temp;
temp = *x;
*x = *y;
*y = temp;
return;
int main ()
int a = 100;
int b = 200;
swap(&a, &b);
);
return 0;
OUTPUT:-
Practical 34
AIM 34: Write program for arrays in c.
AIM 34.1.a : Write a program for declaration without initialization of values using array.
INPUT CODE:-
#include <stdio.h>
int main ()
int a[100];
return 0;
AIM 34.2 : Write a program for declaration with initialization of values using array.
INPUT CODE:-
#include <stdio.h>
int main ()
int a[6]={11,12,21,34,45,65};
return 0;
OUTPUT:-
INPUT CODE:-
#include <stdio.h>
int main ()
int a[6]={11,12,21,34,45,65};
int sum=0;
sum=sum+a[i];
OUTPUT:-
AIM 34.4 : Write a program for find largest number using array.
INPUT CODE:-
#include <stdio.h>
int main ()
int a[6]={11,12,21,34,45,65},max;
max=a[0];
if(max<a[i]){
max=a[i];
return 0;
}
OUTPUT:-
AIM 34.5 : Write a program for DEFINE THE NUMBER IS EVEN OR ODD using array.
INPUT CODE:-
#include <stdio.h>
int main ()
int a[6]={11,12,21,34,45,65};
if(a[i]%2==0){
printf("%d is even\n",a[i]);
else{
printf("%d is odd\n",a[i]);
return 0;
}
OUTPUT:-
INPUT CODE:-
#include <stdio.h>
int main ()
int a[2][3]={{4,5,6},{8,9,7}};
for(int j=0;j<3;j++){
printf("\n");
return 0;
OUTPUT:-
AIM 34.7 : Write a program for Multi dimensional array.
INPUT CODE:-
#include <stdio.h>
int main ()
int a[2][2][3]={{{4,5,6},{8,9,7}},{{8,1,2},{8,6,2}}};
for(int j=0;j<2;j++){
printf("%d",a[i][j][k]);
printf("\n");
printf("\n");
return 0;
}
OUTPUT:-
INPUT CODE:-
#include <stdio.h>
int main ()
int a[5]={10,20,30,40,50};
printf("%d ,",a[i]);
return 0;
OUTPUT:-
Practical 35
AIM 35: Write program for arrays in c.
AIM 35.1 : Write a program for declaration of structure .
INPUT CODE:-
#include <stdio.h>
struct student{
int stu_r_no;
char stu_name;
float stu_marks;
};
int main ()
return 0;
AIM 35.2 : Write a program for of structure to store data of many students .
INPUT CODE:-
#include <stdio.h>
struct student{
int stu_r_no;
char stu_name[20];
float stu_gpa;
}s[5];
int main ()
scanf("%d",&s[i].stu_r_no);
scanf("%s",&s[i].stu_name);
scanf("%f",&s[i].stu_gpa);
printf("\n");
printf("Name: %s \n",s[i].stu_name);
printf("GPA : %f \n",s[i].stu_gpa);
return 0;
OUTPUT:-
AIM 35.4 : Write a program for nesting structure .
INPUT CODE:-
#include <stdio.h>
struct date{
int day;
char month[20];
int year;
};
struct student{
int stu_r_no;
char
stu_name[20];
float stu_gpa;
struct date d;
}s[5];
int main ()
scanf("%d",&s[i].stu_r_no);
",i+1); scanf("%s",&s[i].stu_name);
scanf("%f",&s[i].stu_gpa);
scanf("%d%s%d",&s[i].d.day,&s[i].d.month,&s[i].d.year);
printf("\n");
printf("Name: %s \n",s[i].stu_name);
printf("GPA : %f \n",s[i].stu_gpa);
return 0;
OUTPUT:-
Practical 36
AIM 36: Write program for union in c.
#include<stdio.h>
union student{
int stu_rno;
char stu_name[30];
float stu_marks;
};
int main()
return 0;
}
Practical 37
AIM 37: Write programs for pointers in c.
INPUT CODE:-
#include<stdio.h>
int main()
int n =15;
int *p;
return 0;
INPUT CODE:-
#include<stdio.h>
int main()
int n =15;
int *p;
p =&n;
return 0;
INPUT CODE:-
#include <stdio.h>
int main()
{
int x,y,*a,*b,temp;
a = &x;
b = &y;
temp = *b;
*b = *a;
*a = temp;
return 0;
OUTPUT:-
AIM 37.4 : Write a program for null pointer .
INPUT CODE:-
#include <stdio.h>
int main()
int *p = NULL;
return 0;
OUTPUT:-
AIM 37.5 : Write a program for pointer to array .
INPUT CODE:-
#include <stdio.h>
int main()
int *p;
int a[5]={10,20,30,40,50};
p=&a[0];
int i;
p++;
return 0;
OUTPUT:-
AIM 37.6 : Write a program for double pointer .
#include<stdio.h>
int main(){
int a=50,*p,**pp;
p=&a;
pp = &p;
}
OUTPUT:-
INPUT CODE:-
#include<stdio.h>
int main(){
int n = 50;
int *p;
p=&n;
p=p+1;
OUTPUT:-
AIM 37.7 .b: Write a program for decrement operator in pointer .
INPUT CODE:-
#include<stdio.h>
int main(){
int n = 50;
int *p;
p=&n;
p=p-1;
OUTPUT:-
AIM 37.7 .c: Write a program for addition operator in pointer .
INPUT CODE:-
#include<stdio.h>
int main(){
int n = 50;
int *p;
p=&n;
p=p+2;
OUTPUT:-
AIM 37.7 .d: Write a program for subtraction operator in pointer .
INPUT CODE:-
#include<stdio.h>
int main(){
int n = 50;
int *p;
p=&n;
p=p-3;
OUTPUT:-
Practical 38
AIM 38: Write program for declaration and initialization of a variable in c.
INPUT CODE :-
#include<stdio.h>
int main()
int age;
age = 20;
printf("Age = %d \n",age);
return 0;
OUTPUT:-
Practical 39
AIM 39: Write program to get a number as age and display whether the person is young and adult in c.
INPUT CODE :-
#include<stdio.h>
int main()
int age;
printf("Enter Age:");
scanf("%d",&age);
if(age>=18){
else{
return 0;
}
OUTPUT:-
Practical 40
AIM 40: Write program to check the given character is a vowel or consonant.
INPUT CODE :-
#include <stdio.h>
int main() {
char c;
scanf("%c", &c);
else
return 0;
OUTPUT:-
Practical 41
AIM 41: Write program to reverse an array.
INPUT CODE :-
#include<stdio.h>
int main()
int size;
scanf("%d",&size);
int arr[size];
int i;
scanf("%d",&arr[i]);
printf("%d\t",arr[i]);
return 0;
OUTPUT:-
Practical 42
AIM 42: Write program to calculate the factorial of a given integer using function.
INPUT CODE :-
#include <stdio.h>
int fact(int n)
int i,f=1;
for(i=1;i<=n;i++)
f=f*i;
return f;
int fact(int);
int main()
int no,factorial;
scanf("%d",&no);
factorial=fact(no);
OUTPUT:-
Practical 43
AIM 43: Write program to find the number in palindrome or not.
INPUT CODE :-
#include<stdio.h>
int main()
int n,r,sum=0,temp;
scanf("%d",&n);
temp=n;
while(n>0)
r=n%10;
sum=(sum*10)+r;
n=n/10;
}
if(temp==sum){
else{
return 0;
OUTPUT:-
Practical 44
AIM 44: Write program to read n numbers into an array A.
INPUT CODE :-
#include <stdio.h>
int main()
int n;
int odd_sum=0;
scanf("%d",&n);
int arr[n];
scanf("%d",&arr[i]);
{ if(arr[i]%2!=0){
odd_sum += arr[i];
return 0;
OUTPUT:-
AIM 44.2: Sum of even numbers.
INPUT CODE :-
#include <stdio.h>
int main()
int n;
int even_sum=0;
scanf("%d",&n);
int arr[n];
scanf("%d",&arr[i]);
}
for(int i=0; i<n; i++)
{ if(arr[i]%2==0){
even_sum += arr[i];
return 0;
OUTPUT:-
INPUT CODE :-
#include <stdio.h>
int main()
{
int n;
int total_sum=0;
scanf("%d",&n);
int arr[n];
scanf("%d",&arr[i]);
{ if(arr[i]%2==0){
total_sum += arr[i];
return 0;
OUTPUT:-
Practical 45
AIM 45: Write program for dynamic memory allocation in c.
INPUT CODE :-
#include <stdio.h>
#include <stdlib.h>
int main(){
int n;
printf("For how many data items you want to allocate memory dynamically\n");
scanf("%d", &n);
int *ptr;
if(ptr == NULL){
}else{
ptr[i] = i+1;
return 0;
}OUTPUT:-
Practical 46
AIM 46: Write program for file handling in c.
INPUT CODE :-
#include <stdio.h>
#include <string.h>
int main(){
FILE *fp;
fp = fopen ("new.c","r");
if(fp == NULL){
printf("No exist\n");
}else{
printf("Exist\n");
while(fgets(ch,50,fp)){
printf("%s\n", ch);
fclose(fp);
printf("File closed\n");
}
return 0;
OUTPUT:-