write a c program to Create employee record by taking
details like name, employee id, address and phone number.
While taking the phone number, take either landline or
mobile number. Ensure that the phone numbers of the employee
are unique. Also display all the details
Answers were Sorted based on User's Feedback
Answer / puneet mittal
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
struct Employee
{
char name[20];
int id;
char address[50];
int phno;
};
struct Employee emp[10];
int i,j;
printf("EMPLOYEES RECORD : \n\n");
for(i=0;i<2;i++)
{
printf("\n");
printf("Enter detail of Employee %d\n
",i+1);
printf("Employee name : ");
scanf("&s",&emp[i].name);
printf("Employee id no.: ");
scanf("%d",&emp[i].id);
printf("Address:");
scanf("%s",&emp[i].address);
printf("Phone number(give either
landline or mobile number):");
pass:
scanf("%d",&emp[i].phno);
if(i>0)
{
for(j=0;j<2;j++)
{
if(emp[j].phno==emp[i].phno)
{
printf("this phone number is having
employee id no. - %d ",emp[j].id);
printf("TRY AGAIN . ");
goto pass;
}
}
}
}
getch();
}
Is This Answer Correct ? | 9 Yes | 9 No |
Answer / vinesh2009sharma
void main()
{
printf("enter the EMP NAME EMP ID ..........")
sca
Is This Answer Correct ? | 3 Yes | 10 No |
how to delete an element in an array
void main() { int *i = 0x400; // i points to the address 400 *i = 0; // set the value of memory location pointed by i; }
1. const char *a; 2. char* const a; 3. char const *a; -Differentiate the above declarations.
Is the following code legal? struct a { int x; struct a *b; }
main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }
9 Answers CSC, GoDB Tech, IBM,
main ( ) { static char *s[ ] = {“black”, “white”, “yellow”, “violet”}; char **ptr[ ] = {s+3, s+2, s+1, s}, ***p; p = ptr; **++p; printf(“%s”,*--*++p + 3); }
print numbers till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!
Which one is taking more time and why ? :/home/amaresh/Testing# cat time.c //#include <stdio.h> #define EOF -1 int main() { register int c; while ((c = getchar()) != EOF) { putchar(c); } return 0; } ------------------- WIth stdio.h:- :/home/amaresh/Testing# time ./time_header hi hi hru? hru? real 0 m4.202s user 0 m0.000s sys 0 m0.004s ------------------ Witout stdio.h and with #define EOF -1 =================== /home/amaresh/Testing# time ./time_EOF hi hi hru? hru? real 0 m4.805s user 0 m0.004s sys 0 m0.004s -- From above two case , why 2nd case is taking more time ?
All the combinations of prime numbers whose sum gives 32
main() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); }
#include"math.h" void main() { printf("Hi everybody"); } if <stdio.h> will be included then this program will must compile, but as we know that when we include a header file in "" then any system defined function find its defination from all the directrives. So is this code of segment will compile? If no then why?
main() { show(); } void show() { printf("I'm the greatest"); }