You are on page 1of 14

SHREYAS GUDURI 19BCT0046

ADV C PROGRAMMING DA3

1.
#include<stdio.h>

struct employee

char name[100];

int id;

char address[100];

char designation[111];

int salary;

};

int main()

struct employee e;

printf("enter the details of employee\n");

scanf("%s",&e.name);

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

scanf("%s",&e.address);

scanf("%s",&e.designation);

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

printf("employee details:\n");

printf("%s\n",e.name);
printf("%d\n",e.id);

printf("%s\n",e.address);

printf("%s\n",e.designation);

printf("%d\n",e.salary);

OUTPUT

2.
#include<stdio.h>

struct employee

{
char empname[90],empaddress[90],empdesignation[100];

int empnum,salary;

}emp[10];

int main()

int i,high,n;

printf("\nnumber of employees : ");

scanf("%d",&n);

printf("Enter details for %d employees:",n);

for(i=0;i<n;i++)

printf("\nEmployee Number: ");

scanf("%d",&emp[i].empnum);

printf("Name : ");

scanf("%s",emp[i].empname);

printf("Address : ");

scanf("%s",emp[i].empaddress);

printf("Designation : ");

scanf("%s",emp[i].empdesignation);

printf("Salary : ");

scanf("\n %d",&emp[i].salary);

printf("*******\n");

high=emp[0].salary;

for(i=0;i<n;i++)

if(emp[i].salary>high)

high=emp[i].salary;

}
printf("Highest salary employee details:");

printf("\nEMPNUM EMPNAME SALARY ADDRESS DESIGNATION\n");

for(i=0;i<n;i++)

if(emp[i].salary==high)

printf("\n
%d\t%s\t%d\t%s\t%s",emp[i].empnum,emp[i].empname,emp[i].salary,emp[i].empaddress,emp[i].empd
esignation);

return 0;

OUTPUT

3.
#include <stdio.h>

#include <string.h>

typedef struct employee

int id;
char name[30];

char address[30];

char designation[30];

float salary;

} emp;

int main()

int n;

printf("Number of Employees: ");

scanf("%d", &n);

int i;

emp e[1024];

emp *ptr;

ptr = &e[n];

for (i = 0; i < n; i++)

printf("Name\t\t ID\t\t Salary\t\t Address\t\t Designation\t\t");

scanf("%s %d %f %s %s", &(ptr + i)->name, &(ptr + i)->id, &(ptr + i)->salary, &(ptr + i)->address,
&(ptr + i)->designation);

for (i = 0; i < n; i++)

printf("Name :%s\t\t ID : %d\t\t Salary: %f\t\t Address : %s\t\t Designation : %s\n", (ptr + i)->name,
(ptr + i)->id, (ptr + i)->salary, (ptr + i)->address, (ptr + i)->designation);

int maxsalary = 0;

for (i = 0; i < n; i++)

{
if (maxsalary < (ptr + i)->salary)

maxsalary = (ptr + i)->salary;

printf("\nMaximum Salary is = %d\n", maxsalary);

for (i = 0; i < n; i++)

if ((ptr + i)->salary == maxsalary)

printf("\nHighest Paid Employee: \n");

printf("%s", (ptr+i)->name);

break;

return 0;

OUTPUT

4.
#include<stdio.h>

#include<conio.h>
#define PI 3.141

struct rectangle

int length;

int breadth;

};

struct square

int side;

};

struct circle

int radius;

};

void myftn();

void myftn1();

void myftn2();

int main()

myftn();

myftn1();

myftn2();

struct rectangle r;

struct square s;

struct circle c;
}

void myftn()

int area;

struct rectangle r;

printf("enter measurements of rectangle:\n");

scanf("%d",&r.length);

scanf("%d",&r.breadth);

area=r.length*r.breadth;

printf("area of rectangle:\n");

printf("%d\n",area);

void myftn1()

int area1;

struct square s;

printf("enter the measurements of square:\n");

scanf("%d",&s.side);

area1=(s.side)*(s.side);

printf("area of square:\n");

printf("%d\n",area1);

void myftn2()

float area2;

struct circle c;
printf("enter the requirements of circle: ");

scanf("%d",&c.radius);

area2=PI*(c.radius)*(c.radius);

printf("area of circle:\n");

printf("%f\n",area2);

OUTPUT

5.
#include<stdio.h>

#include<stdlib.h>

struct customer
{

char name[20];

char id[10];

int amount;

}cust;

int main()

int credit,debit;

int n;

cust.amount=2500;

printf("Enter Your Name:");

gets(cust.name);

printf("Enter Your Id:");

gets(cust.id);

while(n!=4)

printf("1.Balance Checking\n");

printf("2.withdraw\n");

printf("3.deposit\n");

printf("4.quit\n");

printf("option:");

scanf("%d",&n);

switch(n)

case 1:

printf("AVAILABALE BALANCE=%d\n",cust.amount);

break;

case 2:
printf("ENTER AMOUNT TO WITHDRAWL:");

scanf("%d",&debit);

cust.amount=cust.amount-debit;

printf("AVAILABLE BALANCE AFTER WITHDRAWL %d\n",cust.amount);

break;

case 3:

printf("ENTER AMOUNT TO DEPOSIT:");

scanf("%d",&credit);

cust.amount=cust.amount+credit;

printf("AVAILABLE BALANCE AFTER DESPOSIT %d\n",cust.amount);

break;

case 4:

break;

}
OUTPUT
6.
A struct in the C programming language is a composite data type declaration that defines a
physically grouped list of variables under one name in a block of memory, allowing the different
variables to be accessed via a single pointer or by the struct declared name which returns the same
address.
Used Structures

7.
#include <stdio.h>

int main()

int i = 0;

begin:

i = i + 1;

printf("%d ", i);

if (i < 100)

goto begin;

return 0;

}
OUTPUT

You might also like