0% found this document useful (0 votes)
17 views42 pages

Assignment 13

Uploaded by

vrunurade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views42 pages

Assignment 13

Uploaded by

vrunurade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

A) Hard Coded and Input from User

Q1)

#include<stdio.h>

#include<string.h>

struct student{

int rollNo;

char name[20];

int marks;

};

void main(){

struct student s1;

s1.rollNo = 101;

s1.marks = 95;

strcpy(s1.name,"Varun urade");

prin ("Name of Student : %s",s1.name);

prin ("\nRoll Number of Student : %d",s1.rollNo);

prin ("\nMarks obtained by Student: %d",s1.marks);

struct student s2;

prin ("\n\nEnter the Name of Student:");

gets(s2.name);

prin ("\nEnter the Roll No. of %s: ",s2.name);

scanf("%d",&s2.rollNo);

prin ("\nEnter the Marks Obtained by %s: ",s2.name);

scanf("%d",&s2.marks);

prin ("Name of Student : %s",s2.name);

prin ("\nRoll Number of Student : %d",s2.rollNo);

prin ("\nMarks obtained by Student: %d",s2.marks);

}
Q2)

#include<stdio.h>

#include<string.h>

struct employee{

int id;

char name[20];

int salary;

};

void main(){

struct employee e1,e2;

e1.id = 101;

e1.salary = 50000;

strcpy(e1.name,"Varun Urade");

prin ("Name of Employee : %s",e1.name);

prin ("\nID Number of Employee : %d",e1.id);

prin ("\nSalary earned by Employee: %d",e1.salary);

prin ("\n\nEnter the name of Employee:");

gets(e2.name);

prin ("\nEnter the ID Number of %s: ",e2.name);

scanf("%d",&e2.id);

prin ("\nEnter the Salary of %s: ",e2.name);

scanf("%d",&e2.salary);

prin ("Name of Employee : %s",e2.name);

prin ("\nID Number of Employee : %d",e2.id);

prin ("\nSalary earned by Employee: %d",e2.salary);

}
Q3)

#include<stdio.h>

#include<string.h>

struct admin{

int id;

char name[20];

int salary;

int allowance;

};

void main(){

struct admin a1,a2;

a1.id = 101;

a1.salary = 50000;

a1.allowance = 5000;

strcpy(a1.name,"Varun urade");

prin ("Name of Admin : %s",a1.name);

prin ("\nID Number of Admin: %d",a1.id);

prin ("\nSalary of Admin : %d",a1.salary);

prin ("\nAllowance of Admin: %d",a1.allowance);

prin ("\n\nEnter the Name of Admin:");

gets(a2.name);

prin ("\nEnter the ID number of %s: ",a2.name);

scanf("%d",&a2.id);

prin ("\nEnter the Salary of %s: ",a2.name);

scanf("%d",&a2.salary);

prin ("\nENter the Allowance of %s: ",a2.name);

scanf("%d",&a2.allowance);

prin ("Name of Admin : %s",a2.name);

prin ("\nID Number of Admin: %d",a2.id);

prin ("\nSalary of Admin : %d",a2.salary);

prin ("\nAllowance of Admin: %d",a2.allowance);


}

Q4)

#include<stdio.h>

#include<string.h>

struct HR{

int id;

char name[20];

int salary;

int commission;

};

void main(){

struct HR h1,h2;

h1.id = 101;

strcpy(h1.name,"Shreyas Ghodchore");

h1.salary = 50000;

h1.commission = 70000;

prin ("Name of HR : %s",h1.name);

prin ("\nID Number of HR : %d",h1.id);

prin ("\nSalary of HR : %d",h1.salary);

prin ("\nCommission of HR: %d",h1.commission);

prin ("\n\nEnter the Name of HR: ");

gets(h2.name);

prin ("\nEnter the ID Number of %s: ",h2.name);

scanf("%d",&h2.id);

prin ("\nEnter the Salary of %s: ",h2.name);

scanf("%d",&h2.salary);

prin ("\nEnter the Commission of %s: ",h2.name);

scanf("%d",&h2.commission);

prin ("Name of HR : %s",h2.name);

prin ("\nID Number of HR : %d",h2.id);

prin ("\nSalary of HR : %d",h2.salary);


prin ("\nCommission of HR: %d",h2.commission);

Q5)

#include<stdio.h>

#include<string.h>

struct salesManager{

int id;

char name[20];

int salary;

int incen ve;

int target;

};

void main(){

struct salesManager m1,m2;

m1.id = 101;

m1.salary = 15000;

m1.target = 200;

m1.incen ve = 2000;

strcpy(m1.name,"Sham Bornar");

prin ("Name of the Sales Manager : %s",m1.name);

prin ("\nID Number of the Sales manager : %d",m1.id);

prin ("\nSalary of Sales Manager : %d",m1.salary);

prin ("\nTarget of the Sales Manager is to Sell at least %d products.",m1.target);

prin ("\nIncen ve of the Sales Manager : %d",m1.incen ve);

prin ("\n\nEnter the Name of the Sales Manager: ");

gets(m2.name);

prin ("\nEnter the ID number of %s: ",m2.name);

scanf("%d",&m2.id);

prin ("\nEnter the Salary of %s: ",m2.name);

scanf("%d",&m2.salary);

prin ("\nEnter the Target of %s: ",m2.name);


scanf("%d",&m2.target);

prin ("\nEnter the Incen ve of %s: ",m2.name);

scanf("%d",&m2.incen ve);

prin ("Name of the Sales Manager : %s",m2.name);

prin ("\nID Number of the Sales manager : %d",m2.id);

prin ("\nSalary of Sales Manager : %d",m2.salary);

prin ("\nTarget of the Sales Manager is to Sell at least %d products.",m2.target);

prin ("\nIncen ve of the Sales Manager : %d",m2.incen ve);

Q6)

#include<stdio.h>

struct date{

int dd;

int mm;

int yyyy;

};

void main(){

struct date d1,d2;

d1.dd = 13;

d1.mm = 01;

d1.yyyy = 2004;

prin ("The Date is: %d-%d-%d",d1.dd,d1.mm,d1.yyyy);

prin ("\n\nEnter the Day: ");

scanf("%d",&d2.dd);

prin ("\nEnter the Month: ");

scanf("%d",&d2.mm);

prin ("\nEnter the Year: ");

scanf("%d",&d2.yyyy);

prin ("The Date is: %d-%d-%d",d2.dd,d2.mm,d2.yyyy);

}
Q7)

#include<stdio.h>

struct me{

int hour;

int minute;

int seconds;

};

void main(){

struct me t1,t2;

t1.hour = 07;

t1.minute = 15;

t1.seconds = 37;

prin ("The me is: %d:%d:%d",t1.hour,t1.minute,t1.seconds);

prin ("\n\nEnter the Hours: ");

scanf("%d",&t2.hour);

prin ("\nEnter the Minutes: ");

scanf("%d",&t2.minute);

prin ("\nEnter the Seconds: ");

scanf("%d",&t2.seconds);

prin ("\nThe me is: %d:%d:%d",t2.hour,t2.minute,t2.seconds);

Q8)

#include<stdio.h>

struct height{

int feet;

int inch;

};

void main(){

struct height h1,h2;

h1.feet = 5;

h1.inch = 9;
prin ("The Height is: %d feet and %d inches",h1.feet,h1.inch);

prin ("\n\nEnter the Feet:");

scanf("%d",&h2.feet);

prin ("\nEnter the Inches:");

scanf("%d",&h2.inch);

prin ("The Height is: %d feet and %d inches",h2.feet,h2.inch);

Q9)

#include<stdio.h>

struct complex{

int real;

int imaginary;

};

void main(){

struct complex c1,c2;

c1.real = 5;

c1.imaginary = 3;

prin ("The Complex Number is: %d + %di",c1.real,c1.imaginary);

prin ("\n\nEnter the Real Part: ");

scanf("%d",&c2.real);

prin ("Enter the Imaginary Part: ");

scanf("%d",&c2.imaginary);

prin ("The Complex Number is: %d + %di",c2.real,c2.imaginary);

Q10)

#include<stdio.h>

#include<string.h>

typedef struct Product{

int id;

char name[20];

float quan ty;


int price;

}Product;

Product store();

void display(Product);

void main(){

struct Product p1,p2;

p1.id = 4791;

strcpy(p1.name,"Sugar");

p1.quan ty = 2.5;

p1.price = 450;

prin ("\nThe Name of Product is : %s",p1.name);

prin ("\nThe ID of Product is : %d",p1.id);

prin ("\nThe Quan ty of Product is : %f kg",p1.quan ty);

prin ("\nThe Price of the Product is: %d Rs.",p1.price);

prin ("\n\nEnter the Name of the Product: ");

gets(p2.name);

prin ("\nEnter the ID of the Product: ");

scanf("%d",&p2.id);

prin ("\nENter the Quan ty of the Product: ");

scanf("%f",&p2.quan ty);

fflush(stdin);

prin ("\nEnter the Price of the Product: ");

scanf("%d",&p2.price);

prin ("\nThe Name of Product is : %s",p2.name);

prin ("\nThe ID of Product is : %d",p2.id);

prin ("\nThe Quan ty of Product is : %f kg",p2.quan ty);

prin ("\nThe Price of the Product is: %d Rs.",p2.price);

}
B) Pass By Value to Func on

Q1)

#include<stdio.h>

#include<string.h>

struct Student{

int rollNo;

char name[20];

int marks;

};

struct Student store();

void display(struct Student);

void main(){

struct Student s1;

s1 = store();

display(s1);

struct Student store(){

struct Student temp;

prin ("Enter the Name of the Student: ");

gets(temp.name);

prin ("\nEnter the Roll No. of the Student: ");

scanf("%d",&temp.rollNo);

prin ("\nEnter the Marks of the Student: ");

scanf("%d",&temp.marks);

return temp;

void display(struct Student temp){

prin ("Name of Student : %s",temp.name);

prin ("\nRoll Number of Student : %d",temp.rollNo);

prin ("\nMarks obtained by Student: %d",temp.marks);

}
Q2)

#include<stdio.h>

#include<string.h>

typedef struct Employee{

int id;

char name[20];

int salary;

}Employee;

Employee store();

void Display(Employee);

void main(){

Employee e1;

e1 = store();

display(e1);

Employee store(){

Employee temp;

prin ("\n\nEnter the name of Employee:");

gets(temp.name);

prin ("\nEnter the ID Number of %s: ",temp.name);

scanf("%d",&temp.id);

prin ("\nEnter the Salary of %s: ",temp.name);

scanf("%d",&temp.salary);

return temp;

void display(Employee temp){

prin ("Name of Employee : %s",temp.name);

prin ("\nID Number of Employee : %d",temp.id);

prin ("\nSalary earned by Employee: %d",temp.salary);

}
Q3)

#include<stdio.h>

#include<string.h>

typedef struct Admin{

int id;

char name[20];

int salary;

int allowance;

}Admin;

Admin store();

void display(Admin);

void main(){

Admin a1;

a1 = store();

display(a1);

Admin store(){

Admin temp;

prin ("\n\nEnter the Name of Admin:");

gets(temp.name);

prin ("\nEnter the ID number of %s: ",temp.name);

scanf("%d",&temp.id);

prin ("\nEnter the Salary of %s: ",temp.name);

scanf("%d",&temp.salary);

prin ("\nENter the Allowance of %s: ",temp.name);

scanf("%d",&temp.allowance);

return temp;

void display(Admin temp){

prin ("Name of Admin : %s",temp.name);

prin ("\nID Number of Admin: %d",temp.id);


prin ("\nSalary of Admin : %d",temp.salary);

prin ("\nAllowance of Admin: %d",temp.allowance);

Q4)

#include<stdio.h>

#include<string.h>

typedef struct HR{

int id;

char name[20];

int salary;

int commission;

}HR;

HR store();

void display(HR);

void main(){

struct HR h1,h2;

h1 = store();

display(h1);

HR store(){

HR temp;

prin ("\n\nEnter the Name of HR: ");

gets(temp.name);

prin ("\nEnter the ID Number of %s: ",temp.name);

scanf("%d",&temp.id);

prin ("\nEnter the Salary of %s: ",temp.name);

scanf("%d",&temp.salary);

prin ("\nEnter the Commission of %s: ",temp.name);

scanf("%d",&temp.commission);

return temp;

}
void display(HR temp){

prin ("Name of HR : %s",temp.name);

prin ("\nID Number of HR : %d",temp.id);

prin ("\nSalary of HR : %d",temp.salary);

prin ("\nCommission of HR: %d",temp.commission);

Q5)

#include<stdio.h>

#include<string.h>

typedef struct salesManager{

int id;

char name[20];

int salary;

int incen ve;

int target;

}SM;

SM store();

void display(SM);

void main(){

struct salesManager m1,m2;

m1 = store();

display(m1);

SM store(){

SM temp;

prin ("\n\nEnter the Name of the Sales Manager: ");

gets(temp.name);

prin ("\nEnter the ID number of %s: ",temp.name);

scanf("%d",&temp.id);

prin ("\nEnter the Salary of %s: ",temp.name);

scanf("%d",&temp.salary);
prin ("\nEnter the Target of %s: ",temp.name);

scanf("%d",&temp.target);

prin ("\nEnter the Incen ve of %s: ",temp.name);

scanf("%d",&temp.incen ve);

return temp;

void display(SM temp){

prin ("Name of the Sales Manager : %s",temp.name);

prin ("\nID Number of the Sales manager : %d",temp.id);

prin ("\nSalary of Sales Manager : %d",temp.salary);

prin ("\nTarget of the Sales Manager is to Sell at least %d products.",temp.target);

prin ("\nIncen ve of the Sales Manager : %d",temp.incen ve);

Q6)

#include<stdio.h>

typedef struct Date{

int dd;

int mm;

int yyyy;

}Date;

Date store();

void display(Date);

void main(){

struct Date d1;

d1 = store();

display(d1);

Date store(){

Date temp;

prin ("\nEnter the Day: ");

scanf("%d",&temp.dd);
prin ("\nEnter the Month: ");

scanf("%d",&temp.mm);

prin ("\nEnter the Year: ");

scanf("%d",&temp.yyyy);

return temp;

void display(Date temp){

prin ("The Date is: %d-%d-%d",temp.dd,temp.mm,temp.yyyy);

Q7)

#include<stdio.h>

typedef struct Time{

int hour;

int minute;

int seconds;

}Time;

Time store();

void display(Time);

void main(){

struct Time t1;

t1 = store();

display(t1);

Time store(){

Time temp;

prin ("\nEnter the Hours: ");

scanf("%d",&temp.hour);

prin ("\nEnter the Minutes: ");

scanf("%d",&temp.minute);

prin ("\nEnter the Seconds: ");

scanf("%d",&temp.seconds);
return temp;

void display(Time temp){

prin ("\nThe me is: %d:%d:%d",temp.hour,temp.minute,temp.seconds);

Q8)

#include<stdio.h>

typedef struct Height{

int feet;

int inch;

}Height;

Height store();

void display(Height);

void main(){

struct Height h1;

h1 = store();

display(h1);

Height store(){

Height temp;

prin ("\n\nEnter the Feet:");

scanf("%d",&temp.feet);

prin ("\nEnter the Inches:");

scanf("%d",&temp.inch);

return temp;

void display(Height temp){

prin ("The Height is: %d feet and %d inches",temp.feet,temp.inch);

Q9)

#include<stdio.h>
typedef struct Complex{

int real;

int imaginary;

}Complex;

Complex store();

void display(Complex);

void main(){

struct Complex c1;

c1 = store();

display(c1);

prin ("\n\nEnter the Real Part: ");

scanf("%d",&c2.real);

prin ("Enter the Imaginary Part: ");

scanf("%d",&c2.imaginary);

prin ("The Complex Number is: %d + %di",c2.real,c2.imaginary);

Complex store(){

Complex temp;

prin ("\n\nEnter the Real Part: ");

scanf("%d",&temp.real);

prin ("Enter the Imaginary Part: ");

scanf("%d",&temp.imaginary);

return temp;

void display(Complex temp){

prin ("The Complex Number is: %d + %di",temp.real,temp.imaginary);

Q10)

#include<stdio.h>

#include<string.h>

typedef struct Product{


int id;

char name[20];

float quan ty;

int price;

}Product;

Product store();

void display(Product);

void main(){

struct Product p1;

p1 = store();

display(p1);

Product store(){

Product temp;

prin ("\n\nEnter the Name of the Product: ");

gets(temp.name);

prin ("\nEnter the ID of the Product: ");

scanf("%d",&temp.id);

prin ("\nENter the Quan ty of the Product: ");

scanf("%f",&temp.quan ty);

fflush(stdin);

prin ("\nEnter the Price of the Product: ");

scanf("%d",&temp.price);

return temp;

void display(Product temp){

prin ("\nThe Name of Product is : %s",temp.name);

prin ("\nThe ID of Product is : %d",temp.id);

prin ("\nThe Quan ty of Product is : %f kg",temp.quan ty);

prin ("\nThe Price of the Product is: %d Rs.",temp.price);

}
C) Array of Structure

Q1)

#include<stdio.h>

#include<string.h>

typedef struct Student{

int rollNo;

char name[20];

int marks;

}Student;

void store(Student*,int);

void display(Student*,int);

void main(){

int size;

prin ("Enter the Size: ");

scanf("%d",&size);

fflush(stdin);

struct Student sarr[size];

store(sarr,size);

display(sarr,size);

void store(Student*sarr,int size){

int i;

for(i=0;i<size;i++){

prin ("\nEnter the Name of the Student %d: ",i+1);

gets(sarr[i].name);

prin ("\nEnter the Roll No. of the Student %d: ",i+1);

scanf("%d",&sarr[i].rollNo);

prin ("\nEnter the Marks of the Student %d: ",i+1);

scanf("%d",&sarr[i].marks);

fflush(stdin);

}
}

void display(Student*sarr,int size){

int i;

for(i=0;i<size;i++){

prin ("\nName of Student %d : %s",i+1,sarr[i].name);

prin ("\nRoll Number of Student %d : %d",i+1,sarr[i].rollNo);

prin ("\nMarks obtained by Student %d: %d\n",i+1,sarr[i].marks);

Q2)

#include<stdio.h>

#include<string.h>

typedef struct Employee{

int id;

char name[20];

int salary;

}Employee;

void store(Employee*,int);

void Display(Employee*,int);

void main(){

int size;

prin ("Enter the Size: ");

scanf("%d",&size);

fflush(stdin);

Employee earr[size];

store(earr,size);

Display(earr,size);

void store(Employee*earr,int size){

int i;

for(i=0;i<size;i++){
prin ("\n\nEnter the name of Employee %d: ",i+1);

gets(earr[i].name);

prin ("\nEnter the ID Number of Employee %d: ",i+1);

scanf("%d",&earr[i].id);

prin ("\nEnter the Salary of Employee %d: ",i+1);

scanf("%d",&earr[i].salary);

fflush(stdin);

void Display(Employee*earr,int size){

int i;

for(i=0;i<size;i++){

prin ("\nName of Employee %d : %s",i+1,earr[i].name);

prin ("\nID Number of Employee %d : %d",i+1,earr[i].id);

prin ("\nSalary earned by Employee %d: %d\n",i+1,earr[i].salary);

Q3)

#include<stdio.h>

#include<string.h>

typedef struct Admin{

int id;

char name[20];

int salary;

int allowance;

}Admin;

void store(Admin*,int);

void display(Admin*,int);

void main(){

int size;

prin ("Enter the Size: ");


scanf("%d",&size);

fflush(stdin);

Admin aarr[size];

store(aarr,size);

display(aarr,size);

void store(Admin*arr,int s){

int i;

for(i=0;i<s;i++){

prin ("\nEnter the Name of Admin %d: ",i+1);

gets(arr[i].name);

prin ("\nEnter the ID number of %d: ",i+1);

scanf("%d",&arr[i].id);

prin ("\nEnter the Salary of %d: ",i+1);

scanf("%d",&arr[i].salary);

prin ("\nENter the Allowance of %d: ",i+1);

scanf("%d",&arr[i].allowance);

fflush(stdin);

void display(Admin*arr,int size){

int i;

for(i=0;i<size;i++){

prin ("\nName of Admin %d : %s",i+1,arr[i].name);

prin ("\nID Number of Admin %d: %d",i+1,arr[i].id);

prin ("\nSalary of Admin %d : %d",i+1,arr[i].salary);

prin ("\nAllowance of Admin %d: %d",i+1,arr[i].allowance);

Q4)

#include<stdio.h>
#include<string.h>

typedef struct HR{

int id;

char name[20];

int salary;

int commission;

}HR;

void store(HR*,int);

void display(HR*,int);

void main(){

int size;

prin ("Enter the Size: ");

scanf("%d",&size);

fflush(stdin);

HR harr[size];

store(harr,size);

display(harr,size);

void store(HR*harr,int size){

int i;

for(i=0;i<size;i++){

prin ("\n\nEnter the Name of HR %d: ",i+1);

gets(harr[i].name);

prin ("\nEnter the ID Number of HR %d: ",i+1);

scanf("%d",&harr[i].id);

prin ("\nEnter the Salary of HR %d: ",i+1);

scanf("%d",&harr[i].salary);

prin ("\nEnter the Commission of HR %d: ",i+1);

scanf("%d",&harr[i].commission);

fflush(stdin);

}
}

void display(HR*harr,int size){

int i;

for(i=0;i<size;i++){

prin ("\nName of HR %d : %s",i+1,harr[i].name);

prin ("\nID Number of HR %d : %d",i+1,harr[i].id);

prin ("\nSalary of HR %d : %d",i+1,harr[i].salary);

prin ("\nCommission of HR %d: %d\n",i+1,harr[i].commission);

Q5)

#include<stdio.h>

#include<string.h>

typedef struct salesManager{

int id;

char name[20];

int salary;

int incen ve;

int target;

}SM;

void store(SM*,int);

void display(SM*,int);

void main(){

int size;

prin ("Enter the Size: ");

scanf("%d",&size);

fflush(stdin);

struct salesManager sarr[size];

store(sarr,size);

display(sarr,size);

}
void store(SM*sarr,int size){

int i;

for(i=0;i<size;i++){

prin ("\nEnter the Name of the Sales Manager %d: ",i+1);

gets(sarr[i].name);

prin ("\nEnter the ID number of Sales Manager %d: ",i+1);

scanf("%d",&sarr[i].id);

prin ("\nEnter the Salary of Sales Manager %d: ",i+1);

scanf("%d",&sarr[i].salary);

prin ("\nEnter the Target of Sales Manager %d: ",i+1);

scanf("%d",&sarr[i].target);

prin ("\nEnter the Incen ve of Sales manager %d: ",i+1);

scanf("%d",&sarr[i].incen ve);

fflush(stdin);

void display(SM*sarr,int size){

int i;

for(i=0;i<size;i++){

prin ("\nName of the Sales Manager %d : %s",i+1,sarr[i].name);

prin ("\nID Number of the Sales manager %d : %d",i+1,sarr[i].id);

prin ("\nSalary of Sales Manager %d : %d",i+1,sarr[i].salary);

prin ("\nTarget of the Sales Manager %d is to Sell at least %d products.",i+1,sarr[i].target);

prin ("\nIncen ve of the Sales Manager %d : %d\n",i+1,sarr[i].incen ve);

Q6)

#include<stdio.h>

typedef struct Date{

int dd;

int mm;
int yyyy;

}Date;

void store(Date*,int);

void display(Date*,int);

void main(){

int size;

prin ("Enter the Size: ");

scanf("%d",&size);

Date darr[size];

store(darr,size);

display(darr,size);

void store(Date*darr,int size){

int i;

for(i=0;i<size;i++){

prin ("\nEnter the Day of Date %d: ",i+1);

scanf("%d",&darr[i].dd);

prin ("\nEnter the Month of Date %d: ",i+1);

scanf("%d",&darr[i].mm);

prin ("\nEnter the Year of Date %d: ",i+1);

scanf("%d",&darr[i].yyyy);

void display(Date*darr,int size){

int i;

for(i=0;i<size;i++){

prin ("The Date %d is: %d-%d-%d\n",i+1,darr[i].dd,darr[i].mm,darr[i].yyyy);

Q7)

#include<stdio.h>
typedef struct Time{

int hour;

int minute;

int seconds;

}Time;

void store(Time*,int);

void display(Time*,int);

void main(){

int size;

prin ("Enter the Size: ");

scanf("%d",&size);

Time tarr[size];

store(tarr,size);

display(tarr,size);

void store(Time*tarr,int size){

int i;

for(i=0;i<size;i++){

prin ("\nEnter the Hours of Time %d: ",i+1);

scanf("%d",&tarr[i].hour);

prin ("\nEnter the Minutes of Time %d: ",i+1);

scanf("%d",&tarr[i].minute);

prin ("\nEnter the Seconds of Time %d: ",i+1);

scanf("%d",&tarr[i].seconds);

void display(Time*tarr,int size){

int i;

for(i=0;i<size;i++){

prin ("\nThe me %d is: %d:%d:%d",i+1,tarr[i].hour,tarr[i].minute,tarr[i].seconds);

}
}

Q8)

#include<stdio.h>

typedef struct Height{

int feet;

int inch;

}Height;

void store(Height*,int);

void display(Height*,int);

void main(){

int size;

prin ("Enter the Size: ");

scanf("%d",&size);

fflush(stdin);

struct Height harr[size];

store(harr,size);

display(harr,size);

void store(Height*harr,int size){

int i;

for(i=0;i<size;i++){

prin ("\nEnter the Feet of Height %d: ",i+1);

scanf("%d",&harr[i].feet);

prin ("\nEnter the Inches of Height %d: ",i+1);

scanf("%d",&harr[i].inch);

void display(Height*harr,int size){

int i;

for(i=0;i<size;i++){

prin ("The Height %d is: %d feet and %d inches\n",i+1,harr[i].feet,harr[i].inch);


}

Q9)

#include<stdio.h>

typedef struct Complex{

int real;

int imaginary;

}Complex;

void store(Complex*,int);

void display(Complex*,int);

void main(){

int size;

prin ("Enter the Size: ");

scanf("%d",&size);

fflush(stdin);

Complex carr[size];

store(carr,size);

display(carr,size);

void store(Complex*carr,int size){

int i;

for(i=0;i<size;i++){

prin ("\n\nEnter the Real Part of number %d: ",i+1);

scanf("%d",&carr[i].real);

prin ("Enter the Imaginary Part of number %d: ",i+1);

scanf("%d",&carr[i].imaginary);

void display(Complex*carr,int size){

int i;

for(i=0;i<size;i++){
prin ("\nThe Complex Number %d is: %d + %di",i+1,carr[i].real,carr[i].imaginary);

Q10)

#include<stdio.h>

#include<string.h>

typedef struct Product{

int id;

char name[20];

float quan ty;

int price;

}Product;

void store(Product*,int);

void display(Product*,int);

void main(){

int size;

prin ("Enter the Size: ");

scanf("%d",&size);

fflush(stdin);

Product parr[size];

store(parr,size);

display(parr,size);

void store(Product*parr,int size){

int i;

for(i=0;i<size;i++){

prin ("\nEnter the Name of the Product %d: ",i+1);

gets(parr[i].name);

prin ("\nEnter the ID of the Product %d: ",i+1);

scanf("%d",&parr[i].id);

prin ("\nENter the Quan ty of the Product %d: ",i+1);


scanf("%f",&parr[i].quan ty);

fflush(stdin);

prin ("\nEnter the Price of the Product %d: ",i+1);

scanf("%d",&parr[i].price);

fflush(stdin);

void display(Product*parr,int size){

int i;

for(i=0;i<size;i++){

prin ("\nThe Name of Product is %d : %s",i+1,parr[i].name);

prin ("\nThe ID of Product is %d : %d",i+1,parr[i].id);

prin ("\nThe Quan ty of Product is %d : %f kg",i+1,parr[i].quan ty);

prin ("\nThe Price of the Product is %d: %d Rs.\n",i+1,parr[i].price);

}
D) Pass By Address to Func on

Q1)

#include<stdio.h>

#include<string.h>

typedef struct Student{

int rollNo;

char name[20];

int marks;

}Student;

void store(Student*);

void display(Student*);

void main(){

struct Student s1;

store(&s1);

display(&s1);

void store(Student*temp){

prin ("Enter the Name of the Student: ");

gets(temp->name);

prin ("\nEnter the Roll No. of the Student: ");

scanf("%d",&temp->rollNo);

prin ("\nEnter the Marks of the Student: ");

scanf("%d",&temp->marks);

void display(Student*temp){

prin ("Name of Student : %s",temp->name);

prin ("\nRoll Number of Student : %d",temp->rollNo);

prin ("\nMarks obtained by Student: %d",temp->marks);

Q2)

#include<stdio.h>
#include<string.h>

typedef struct Employee{

int id;

char name[20];

int salary;

}Employee;

void store(Employee*);

void Display(Employee*);

void main(){

Employee e1;

store(&e1);

display(&e1);

void store(Employee*temp){

prin ("\nEnter the name of Employee:");

gets(temp->name);

prin ("\nEnter the ID Number of %s: ",temp->name);

scanf("%d",&temp->id);

prin ("\nEnter the Salary of %s: ",temp->name);

scanf("%d",&temp->salary);

void display(Employee*temp){

prin ("Name of Employee : %s",temp->name);

prin ("\nID Number of Employee : %d",temp->id);

prin ("\nSalary earned by Employee: %d",temp->salary);

Q3)

#include<stdio.h>

#include<string.h>

typedef struct Admin{

int id;
char name[20];

int salary;

int allowance;

}Admin;

void store(Admin*);

void display(Admin*);

void main(){

Admin a1;

store(&a1);

display(&a1);

void store(Admin*temp){

prin ("\nEnter the Name of Admin:");

gets(temp->name);

prin ("\nEnter the ID number of %s: ",temp->name);

scanf("%d",&temp->id);

prin ("\nEnter the Salary of %s: ",temp->name);

scanf("%d",&temp->salary);

prin ("\nENter the Allowance of %s: ",temp->name);

scanf("%d",&temp->allowance);

void display(Admin*temp){

prin ("Name of Admin : %s",temp->name);

prin ("\nID Number of Admin: %d",temp->id);

prin ("\nSalary of Admin : %d",temp->salary);

prin ("\nAllowance of Admin: %d",temp->allowance);

Q4)

#include<stdio.h>

#include<string.h>

typedef struct HR{


int id;

char name[20];

int salary;

int commission;

}HR;

void store(HR*);

void display(HR*);

void main(){

struct HR h1;

store(&h1);

display(&h1);

void store(HR*temp){

prin ("\nEnter the Name of HR: ");

gets(temp->name);

prin ("\nEnter the ID Number of %s: ",temp->name);

scanf("%d",&temp->id);

prin ("\nEnter the Salary of %s: ",temp->name);

scanf("%d",&temp->salary);

prin ("\nEnter the Commission of %s: ",temp->name);

scanf("%d",&temp->commission);

void display(HR*temp){

prin ("\nName of HR : %s",temp->name);

prin ("\nID Number of HR : %d",temp->id);

prin ("\nSalary of HR : %d",temp->salary);

prin ("\nCommission of HR: %d",temp->commission);

Q5)

#include<stdio.h>

#include<string.h>
typedef struct salesManager{

int id;

char name[20];

int salary;

int incen ve;

int target;

}SM;

void store(SM*);

void display(SM*);

void main(){

struct salesManager m1;

store(&m1);

display(&m1);

void store(SM*temp){

prin ("\nEnter the Name of the Sales Manager: ");

gets(temp->name);

prin ("\nEnter the ID number of %s: ",temp->name);

scanf("%d",&temp->id);

prin ("\nEnter the Salary of %s: ",temp->name);

scanf("%d",&temp->salary);

prin ("\nEnter the Target of %s: ",temp->name);

scanf("%d",&temp->target);

prin ("\nEnter the Incen ve of %s: ",temp->name);

scanf("%d",&temp->incen ve);

void display(SM*temp){

prin ("Name of the Sales Manager : %s",temp->name);

prin ("\nID Number of the Sales manager : %d",temp->id);

prin ("\nSalary of Sales Manager : %d",temp->salary);

prin ("\nTarget of the Sales Manager is to Sell at least %d products.",temp->target);


prin ("\nIncen ve of the Sales Manager : %d",temp->incen ve);

Q6)

#include<stdio.h>

typedef struct Date{

int dd;

int mm;

int yyyy;

}Date;

void store(Date*);

void display(Date*);

void main(){

Date d1;

store(&d1);

display(&d1);

void store(Date*temp){

prin ("\nEnter the Day: ");

scanf("%d",&temp->dd);

prin ("\nEnter the Month: ");

scanf("%d",&temp->mm);

prin ("\nEnter the Year: ");

scanf("%d",&temp->yyyy);

void display(Date*temp){

prin ("\nThe Date is: %d-%d-%d",temp->dd,temp->mm,temp->yyyy);

Q7)

#include<stdio.h>

typedef struct Time{

int hour;
int minute;

int seconds;

}Time;

void store(Time*);

void display(Time*);

void main(){

Time t1;

store(&t1);

display(&t1);

void store(Time*temp){

prin ("\nEnter the Hours: ");

scanf("%d",&temp->hour);

prin ("\nEnter the Minutes: ");

scanf("%d",&temp->minute);

prin ("\nEnter the Seconds: ");

scanf("%d",&temp->seconds);

void display(Time*temp){

prin ("\nThe me is: %d:%d:%d",temp->hour,temp->minute,temp->seconds);

Q8)

#include<stdio.h>

typedef struct Height{

int feet;

int inch;

}Height;

void store(Height*);

void display(Height*);

void main(){

Height h1;
store(&h1);

display(&h1);

void store(Height*temp){

prin ("\nEnter the Feet:");

scanf("%d",&temp->feet);

prin ("\nEnter the Inches:");

scanf("%d",&temp->inch);

void display(Height*temp){

prin ("\nThe Height is: %d feet and %d inches",temp->feet,temp->inch);

Q9)

#include<stdio.h>

typedef struct Complex{

int real;

int imaginary;

}Complex;

void store(Complex*);

void display(Complex*);

void main(){

Complex c1;

store(&c1);

display(&c1);

void store(Complex*temp){

prin ("\nEnter the Real Part: ");

scanf("%d",&temp->real);

prin ("Enter the Imaginary Part: ");

scanf("%d",&temp->imaginary);

}
void display(Complex*temp){

prin ("\nThe Complex Number is: %d + %di",temp->real,temp->imaginary);

Q10)

#include<stdio.h>

#include<string.h>

typedef struct Product{

int id;

char name[20];

float quan ty;

int price;

}Product;

void store(Product*);

void display(Product*);

void main(){

Product p1;

store(&p1);

display(&p1);

void store(Product*temp){

prin ("\nEnter the Name of the Product: ");

gets(temp->name);

prin ("\nEnter the ID of the Product: ");

scanf("%d",&temp->id);

prin ("\nENter the Quan ty of the Product: ");

scanf("%f",&temp->quan ty);

fflush(stdin);

prin ("\nEnter the Price of the Product: ");

scanf("%d",&temp->price);

void display(Product*temp){
prin ("\nThe Name of Product is : %s",temp->name);

prin ("\nThe ID of Product is : %d",temp->id);

prin ("\nThe Quan ty of Product is : %f kg",temp->quan ty);

prin ("\nThe Price of the Product is: %d Rs.",temp->price);

You might also like