C Pratical
C Pratical
#include<conio.h>
int main()
char array[100];
clrscr();
printf("\n");
printf("Enter a string\n");
scanf("%s", array);
printf("\n");
getch();
}
OUTPUT
Practical No:2
#include<conio.h>
main()
char c;
c=getchar();
putchar(c);
c=getche();
putchar(c);
c=getch();
getch();}
OUTPUT
Practical No:3
Strlen()
#include<stdio.h>
#include <string.h>
#include<conio.h>
int main()
clrscr();
getch();
}
OUTPUT
strcpy():-
INPUT
#include<stdio.h>
#include<string.h>
#include <conio.h>
int main ()
char str3[40];
char str4[40];
clrscr();
strcpy(str2, str1);
strcpy(str4, str5);
getch();
}
OUTPUT
strcmp():-
INPUT
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
char str1[20];
char str2[20];
int value;
clrscr();
scanf("%s",str1);
scanf("%s",str2);
if(strcmp(str1,str2)==0)
else
getch();
}
OUTPUT
strcat():-
INPUT
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
char str1[20];
char str2[20];
clrscr();
scanf("%s",str1);
scanf("%s",str2);
strcat(str1,str2);
getch();
}
OUTPUT
strrev():-
INPUT
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
char str1[20];
clrscr();
scanf("%s",str1);
strrev(str1);
getch();
}
OUTPUT
Practical No:4
#include<string.h>
#include<conio.h>
int main()
char str1[20],str2[20];
scanf("%s",str1);
strcpy(str2,str1);
strrev(str2);
if(strcmp(str2,str1)==0)
printf("*String is Palindrome");
else
getch();
}
OUTPUT
Practical No:5
#include<conio.h>
main()
struct student
int roll;
char name[20];
int age;
char Std[8];
};
clrscr();
s2=s1;
printf("Name :%s\n",s2.name);
printf("Age :%d\n",s2.age);
printf("Class :%s\n",s2.Std);
getch();
}
OUTPUT
Practical No:6
#include<string.h>
#include<conio.h>
struct student
int roll,marks;
char name[50];
main()
int i,t,avg=0;
int n;
clrscr();
scanf("%d",&n);
for(i=1;i<=n;i++)
printf("\n*enter name:-");
scanf("%s",s[i].name);
printf("*enter marks:-");
scanf("%d",&s[i].marks);
for(i=1,t=0;i<=n;i++)
t=t+s[i].marks;
avg=t/2;
getch();
}
OUTPUT
Practical No:7
#include<conio.h>
struct student
int roll;
char name[20];
int age;
};
struct student s;
printf("#Roll no.:");
scanf("%d",&s.roll);
printf("#Name:");
scanf("%s",s.name);
printf("#Age:");
scanf("%d",&s.age);
return s;
main()
clrscr();
st=read_data();
printf("#Roll no.:%d\n",st.roll);
printf("#Name:%s\n",st.name);
printf("#Age:%d\n",st.age);
getch();
}
OUTPUT
Practical No:8
#include <string.h>
#include <conio.h>
struct student
int id;
char name[20];
float percentage;
};
int main()
clrscr();
printf("\n");
record.id=1;
strcpy(record.name, "Mansi");
record.percentage = 86.5;
func(record);
getch();
}
OUTPUT
Practical No:9
#include <string.h>
#include<conio.h>
struct student
int id;
char name[20];
float percentage;
};
int main()
clrscr();
printf("\n");
record.id=1;
strcpy(record.name, "Gunnu");
record.percentage = 86.5;
func(&record);
getch();
}
OUTPUT
Practical No:10
#include <conio.h>
struct person
int age,weight;
};
int main()
OUTPUT
Practical No:11
#include<conio.h>
main()
int alpha;
int *beta;
clrscr();
alpha=1;
beta= α
printf("\n");
getch();
}
OUTPUT