Professional Documents
Culture Documents
Ansh Singhal Jeg221693 12 A
Ansh Singhal Jeg221693 12 A
week 12 a
Ans 1.)
#include<stdio.h> struct
student{
char
name[20];
int number;
int rank;
}s1;
int main(){
printf("Enter the details of student:\n");
printf("Enter the name of student:");
gets(s1.name);
printf("Enter the roll number of the
student:"); scanf("%d",&s1.number);
printf("Enter the rank of the student:");
scanf("%d",&s1.rank);
struct student *ptr = &s1; printf("\
nCandidate name:%s\n",ptr->name);
printf("Roll number:%d\n",ptr->number);
printf("Rank is:%d",ptr->rank);
return 0;
}
Ans2.)
#include<stdi.h> int
comp(int a, int b);
int
main
()
{ int
n,m;
printf("Enter the first number:");
scanf("%d",&n);
printf("Enter the second number:");
scanf("%d",&m);
comp(n,m);
return 0;
}
int comp(int a,int b){
if(a>=b){
int *ptr=&a;
printf("The value of the greater number is:%d\n", *ptr);
printf("The address of the greater number is:%d", ptr);
}
else{
int *ptr=&b;
printf("The value of the greater number is:%d\n", *ptr);
printf("The address of the greater number is:%d", ptr);
}
}