write a c program to store and print name,address,roll.no of
a student using structures?
Answer Posted / raj
#include<string.h>
#include<conio.h>
#include<stdio.h>
struct student
{
char name[20],adr[5][10];
int no;
}s;
main()
{
int i,j;
clrscr();
scanf("%d",&s.no,printf("enter no of the student:"));
scanf("%s",s.name,printf("enter name of student:"));
printf("enter address(5 lines):\n");
for(i=0;i<=5;i++)
{
j=0;
while((s.adr[i][j++]=getchar())!='\n');
}
printf("\nstudent details are:\n\nRoll.no: %d\n\nName :
%s\n\nadress:",s.no,s.name);
for(i=0;i<=5;i++)
printf("\t%s",s.adr[i]);
getch();
}
| Is This Answer Correct ? | 33 Yes | 28 No |
Post New Answer View All Answers
Explain what is the difference between a free-standing and a hosted environment?
What do you mean by scope of a variable in c?
what are the advantages of a macro over a function?
What is assert and when would I use it?
How can you find the exact size of a data type in c?
can we implement multi-threads in c.
the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?
What is a null string in c?
What is character set?
What is volatile c?
What is the use of typedef in structure in c?
What are preprocessor directives in c?
Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.
You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.
Can an array be an Ivalue?