0% found this document useful (0 votes)
38 views18 pages

POP Set - 1 Solution

Uploaded by

Pooja Patil
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)
38 views18 pages

POP Set - 1 Solution

Uploaded by

Pooja Patil
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/ 18

POP Model paper – 1(SOLUTION)

1. a)Define computer. Describe the various types of computers based on speed, memory and cost.
Ans:
Computer is an electronic device which is capable of receiving information or data and perform a series of
operations in accordance with a set of instructions and produces results in the form of data or information.
Computers can be categorized based on size, performance and application as follows:
i) Super Computer:
 Supercomputers are fastest computers and are very expensive.
 These are employed for specialized applications that require immense amounts of mathematical calculations.
For example, weather forecasting requires a supercomputer.
 Other uses of supercomputers include animated graphics, fluid dynamic calculations, nuclear energy research,
and petroleum exploration.

ii) Mainframe Computer:


 It is a very large and expensive computer and is capable of supporting hundreds, or even thousands of users
simultaneously.
 In the hierarchy that starts with a simple microprocessor (in watches, for example) at the bottom and moves to
supercomputers at the top, mainframes are just below supercomputers.
 In some ways, mainframes are more powerful than supercomputers because they support simultaneous
programs.
 But supercomputers can execute a single program faster than a mainframe.
 The chief difference between a supercomputer and a mainframe is that a supercomputer channels all its power
into executing a few programs as fast as possible, whereas a mainframe uses its power to execute many
programs concurrently.

iii) Mini Computer:


 It is a mid-sized computer in size and power. It lies between workstations and mainframes.
 In the past decade, the distinction between large minicomputers and small mainframes has blurred.
 In general, a minicomputer is a multiprocessing system capable of supporting from 4 to about 200 users
simultaneously.

iv) Micro Computer:


i. Desktop Computer: a personal or micro-mini computer sufficient to fit on a desk.
ii. Laptop Computer: a portable computer completes with an integrated screen and keyboard. It is generally
smaller in size than a desktop computer and larger than a notebook computer.
iii. Palmtop Computer/Digital Diary /Notebook /PDAs (Personal Digital Assistant): a hand-sized
computer, Palmtop, does not have keyboard, but its screen serves both as an input and output device.

v) Smartphones and Embedded Computers:


 The relentless drive toward miniaturization has led to the emergence of two types of devices called
smartphones and embedded computers.
 The smartphone is a general-purpose computer that is also capable of making phone calls.
 The smartphone has a powerful processor, usually with multiple cores. It also supports gigabytes of main
memory but doesn’t have a hard disk for secondary storage. Smartphones today run a well-developed
operating system (Android or iOS), and can run a wide range of applications (popularly called “apps”). Like a
computer, a smartphone has a keyboard and a high-resolution display, both operated by touch or a stylus.
Applications are written in a high-level language— Objective-C for the iPhone and Java for Android phones.
 The embedded computer is a small computer-like system that is part of a larger system.
 Embedded computers (also called micro-controllers) arrived before smartphones. These are very small circuits
containing a CPU, non-volatile memory, and input and output handling facilities. They are embedded into
many of the machines that we use—cars, washing machines, MP3 players and cameras. The processor here
runs a single unmodifiable program stored in memory. Embedded computers can’t match the capabilities of a
smartphone, but they don’t need to. Because the processor is dedicated to a specific task, its capabilities are
just adequate to operate the device.
b)Develop an algorithm to find the area and perimeter of a circle. Also define an algorithm.
Ans:
Algorithm is a finite sequence of instructions, each of which has a clear meaning and can be performed with a
finite amount of effort in a finite length of time.
#include<stdio.h>
#define pi 3.142
void main()
{
float r,a,p;
printf(“Enter radius value:”);
scanf(“%f”,&r);
a=pi*r*r;
p=2*pi*r;
printf(“Area of circle is = %f ”,a);
printf(“Perimeter of circle is = %f ”,p);
}

c)Write a short note characteristics on computer.


Ans:
The major characteristics of a computer are:
i. Speed: As you know computer can work very fast. It takes only a fraction of a second for calculations that
manually take hours to complete. It takes few minutes for the computer to process huge amount of data and
give the result.
ii. Accuracy: The degree of accuracy of computer is very high and every calculation is performed with the same
accuracy. The accuracy level is determined on the basis of design of the computer. The errors in computer
are mainly due to human and inaccurate data.
iii. Diligence: A computer is free from tiredness, lack of concentration, fatigue, etc. It can work for hours without
any error.
iv. Versatility: The computer is highly versatile. You can use it for a number of tasks simultaneously such as, for
inventory management, preparation of electrical bills, preparation of pay cheques, etc. Similarly, in libraries
computer can be used for various library, house-keeping operations like acquisition, circulation, serial
control, etc. and also by students for searching library books on the computer terminal.
v. Storage: Computer has the power of storing large amount of information or data. Any information can be
stored and recalled whenever required for any numbers of years. It depends entirely upon you how much
data you want to store in a computer and when to retrieve or delete stored data.
vi. Reduction of cost: Though initial investment may be high; computer substantially reduces the cost of
transaction.
vii. Automation: Computers are automatable devices that can perform a task without human intervention.
2. a)What is variable? What are the rules to construct variable? Classify the following as valid/invalid
identifiers. i)num2 ii)$num1 iii)+add iv)a_2 v)199_space vi)_apple vii)#12
Ans:
Variable is a named location in a memory where a program can manipulate the data.
The rules to construct variables are:
 They can contain letters, digits and underscores.
 They should not begin with any special characters except underscore (_).
 They are case sensitive.
 They cannot contain whitespaces or special characters like !, #, %, etc.
 Reserved words cannot be used as variables(such as int, float, char etc.).

Valid: num2, a_2, _apple.


Invalid: $num1, +add, 199_space, #12.

Start
b)Draw a flowchart and C program which takes as input p,t,r. Compute the
simple interest and display the result.
Ans: Read p,t,r
#include<stdio.h>
void main()
{ compute si=(p*t*r)/100
float p,t,r,si;
printf(“Enter the P,T,R values\n”);
scanf(“%f %f %f”,&p,&t,&r); Display SI = si
si=(p*t*r)/100;
printf(“Simple interest = %f”,si);
} Stop
c)Write a note on following operators. i)Relational ii)Logical iii)Conditional
Ans:
i) Relational Operator:
Relational operators are used to determine the relationship of one quantity to another. It is used to compare
values of two expressions depending on their relation. They always return 1 or 0 depending upon the outcome
of the test.
Operator Description Example
== Equal to A == B
!= Not equal to A != B
< Less than A<B
> Greater than A>B
<= Less than or equal to A <= B
>= Greater than or equal to A >= B
ii) Logical Operator:
Logical operators are usually used with conditional statements. Operators used with one or more operand and
return either value zero (for false) or one (for true). The operand may be constant, variables or expressions. And
the expression that combines two or more expressions is termed as logical expression.
The three basic logical operators are: -
 AND ( && ) : - Takes two or more inputs and produces high/true output if all inputs are high.
 OR ( || ) : - Takes two or more inputs and produces high output if any one of input is high/true.
 NOT ( ! ) : - Takes one input and inverts input as output.

iii) Conditional Operator:


It sometimes called as ternary operator. It requires three operands and it is represented as (? :).
Syntax: - exp1 ? exp2:exp3
Here exp1 is first evaluated. It is true then value return will be exp2. If false then exp3.
3. a)Develop a C program that takes three coefficients (a,b,c) of a quadratic equation; (ax2+bx+c) as input
and compute all possible roots and print them with appropriate messages.
Ans: #include<stdio.h>
#include<math.h>
void main()
{
float a,b,c,d,real,img,root1,root2;
printf(“\nEnter the values of a,b,c\n”);
if(a = = 0)
printf(“\n Invalid coefficients, roots cannot be computed\n”);
else
{
d=b*b-4*a*c;
printf(“\n The value of discriminant(d) is = %f”,d);
if(d = = 0)
{
root1=root2= -b/(2*a);
printf(“\n The real and equal roots are: root1 = root2 = %.2f”,root1);
}
else if(d > 0)
{
root1 = (-b+sqrt(d))/(2*a);
root2 = (-b-sqrt(d))/(2*a);
printf(“\n The real and distinct roots are: root1=%.2f & root2=%.2f”,root1,root2);
}
else
{
real = -b/(2*a);
img = sqrt(fabs(d))/(2*a);
printf(“\nThe Complex roots are: root1=%.2f+%.2fi & root2=%.2f-%.2fi”,real,img,real,img);
}}}

b)Explain the working of goto statement in C with example.


Ans:
The goto statement is known as jump statement in C. As the name suggests, goto is used to transfer the program
control to a predefined label. The goto statement can be used to repeat some part of the code for a particular
condition. It can also be used to break the multiple loops which can't be done by using a single break statement.
However, using goto is avoided these days since it makes the program less readable and complicated.
Syntax: 1)Forward Jump: 2)Backward jump:
goto Label: Label: statement;
----------- ----------------------
----------- ----------------------
Label: statement; goto Label;
Example:
#include <stdio.h>
void main()
{
int num,i=1;
printf("Enter the number whose table you want to print?");
scanf("%d",&num);
table:
printf("%d x %d = %d\n",num,i,num*i);
i++;
if(i<=10)
goto table;
}
c)Explain switch statement with syntax and example.
Ans:
Switch statement is also called as multi-way branching statement. The switch statement tests the value of a
given variable (or expression) against a list of case values and when a match is found, a block of statements
associated, with that case is executed.
Syntax:
switch(expression)
{
case value-1: block-1;
break;
case value-2: block-2;
break;
--------------------------
--------------------------
default: default-block;
break;
}
Example:
#include <stdio.h>
void main ()
{
char grade;
printf(“\n enter the grade of your choice:”);
scanf(“%c”,&grade);
switch(grade)
{
case 'A' : printf("Excellent!\n" );
break;
case 'B' : printf(“ well done\n”);
break;
case 'C' : printf(“you are passed\n" );
break;
case 'D‘:printf(“Better try again\n" );
break;
default:printf("Invalid grade\n" );
}
}
4. a) Develop a simple calculator program in C language to do simple operations like addition, subtraction,
multiplication and division. Use switch statement in your program.
Ans: #include<stdio.h>
void main()
{
char op;
float n1,n2,result=0;
printf(“\nEnter an operator(+,-,*,/): ”);
scanf(“%c”,op);
printf(“\nEnter the value of two operands: n1 and n2: ”);
scanf(“%f %f”,&n1,&n2);
switch(op)
{
case ‘+’:result = n1+n2;
break;
case ‘-’:result = n1-n2;
break;
case ‘*’:result = n1*n2;
break;
case ‘/’:result = n1/n2;
break;
default:printf(“\nYou have entered an invalid operator”);
}
printf(“%f %c %f = %f”,n1,op,n2,result);
}

b) Explain with examples formatted input output statements in C.


Ans:
i) scanf(): -
The scanf() function is an input function. It used to read the mixed type of data from keyboard. You
can read integer, float and character data by using its control codes or format codes.
Syntax: scanf(“control strings”,arg1, arg2, ….., argn);
Example:
#include <stdio.h>
void main( )
{
int num1, num2,sum;
printf("Enter two integers: ");
scanf("%d %d", &num1, &num2);
sum = num1 + num2;
printf(“sum of %d & %d is %d", num1, num2, sum);
}

ii) printf(): - This is an output function. It is used to display a text message and to display the mixed type (int,
float, char) of data on screen.
Syntax: printf(“control strings”,arg1, arg2,…..,arg3);
Example:
#include <stdio.h>
void main( )
{
int num1, num2,product;
printf("Enter two integers: ");
scanf("%d %d", &num1, &num2);
product = num1 * num2;
printf(“sum of %d & %d is %d", num1, num2, product);
}
c) Explain with syntax, if and if-else statements in C program.
Ans:
i) if: It executes the statement or set of commands when the condition is true.
Syntax:
if(condition)
{
statement x;
}
Example: #include<stdio.h>
void main( )
{
int age;
printf (“ enter the age:”);
scanf(“%d”,&age);
if (age>=18)
printf(“ eligible for voting”);
}
ii) if-else: An if statement can be followed by an optional else statement. If the expression evaluates to true,
then the if block of code will be executed, otherwise else block of code will be executed.
Syntax:
if(condition)
{
statement 1;
}
else
{
statement 2;
}
Example: #include<stdio.h>
void main( )
{
int age;
printf (“ enter the age:”);
scanf(“%d”,&age);
if (age>=18)
printf(“ eligible for voting”);
else
printf(“Not eligible for voting”);
}
5. a) Write a C program to swapping of 2 numbers using call by reference and call by value.
Ans:
Call by value:
#include<stdio.h>
void swapping(int a, int b);
void main()
{
int x,y;
printf(“Enter x, y values\n”);
scanf(“%d %d”,&x,&y);
printf(“Before swapping\n”);
printf(“%d %d”,x,y);
swapping(x,y);
}
void swapping(int a, int b)
{
int temp;
temp = a;
a = b;
b = temp;
printf(“After swapping\n”);
printf(“%d %d”,a,b);
}
Call by reference:
#include<stdio.h>
void swapping(int *a, int *b);
void main()
{
int x,y;
printf(“Enter x, y values\n”);
scanf(“%d %d”,&x,&y);
printf(“Before swapping\n”);
printf(“%d %d”,x,y);
swapping(&x,&y);
}
void swapping(int *a, int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
printf(“After swapping\n”);
printf(“%d %d”,*a,*b);
}

b) –no question…
Ans: - - - - -
c) Discuss the implementation of user defined function with suitable example.
Ans:
User defined functions are the functions written by the user to perform some specific task.
Example:
#include <stdio.h>
int add (int x, int y); //Function prototype
void main()
{
int a,b,c;
printf (“enter any two numbers/n);
scanf(“%d%d”, &a, &b);
c=add (a,b); //Calling the function
printf(“sum =%d”, c);
} Passing arguments to function
int add (int x, int y)
{
int sum;
sum =x+y; Function Definition
return sum;
}
6. a) Write a C program to find the product of two given matrix.
Ans:
#include<stdio.h>
void main()
{
int a[10][10],b[10][10],c[10][10];
int m,n,p,q,i,j,k;
printf("\n enter the order of the matrix A\n");
scanf("%d%d",&m,&n);
printf("\n enter the order of the matrix B\n");
scanf("%d%d",&p,&q);
if(n!=p)
printf("\n Invalid inputs, Multiplication is not Possible \n");
else
{
printf("\n enter the elements of matrix A\n");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
printf("\n enter the elements of matrix B\n");
for(i=0;i<p;i++)
for(j=0;j<q;j++)
scanf("%d",&b[i][j]);
for(i=0;i<m;i++)
for(j=0;j<q;j++)
{
c[i][j]=0;
for(k=0;k<p;k++)
c[i][j] = c[i][j]+a[i][k]*b[k][j];
}
printf(" \n The Resultant Matrix is: \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf("%d\t",c[i][j]);
printf("\n");
}
}
}
b) Explain the working of recursion with suitable example.
Ans:
A recursive function is defined as a function that calls itself to solve a smaller version of its task until a final call is
made which does not require a call to itself.
Example:
#include<stdio.h>
int fact(int n);
void main()
{
int num;
printf(“Enter a number\n”);
scanf(“%d”,&num);
printf(“Factorial of %d = %d”,num,fact(num));
}
int fact(int n)
{
if(n= = 1)
return 1;
return (n*fact(n-1));
}

c) Explain the declaration and initialization of one dimensional and two dimensional arrays with an
example.
Ans:
1-D array:
Declaration Syntax  datatype array_name[size];
Initialization Syntax  datatype array_name[size]={v1,v2,v3,………,vn};
Example: #include<stdio.h>
void main()
{
int a[10]={1,2,3,4,5},i,n;
printf(“enter the size of array:”);
scanf(“%d”,&n);
printf(“enter 5 integer values for array:”);
for(i=5;i<10;i++)
scanf(“%d”, &a[i]);
printf(“the array elements are: \n”);
for (i=0;i<10;i++)
printf(“%d\t”, a[i]);
}
2-D array:
Declaration Syntax  datatype array_name[row_size][column_size];
Initialization Syntax  datatype array_name[row_size][column_size]={v1,v2,v3,………,vn};
Example: #include<stdio.h>
void main()
{
int a[2][3]={1,2,3,4,5,6},i,;
printf(“The array elements are: \n”);
for (i=0;i<2;i++)
for(j=0;j<3;j++)
printf(“%d\t”, a[i][j]);
}
7. a) Develop a C program to concatenate 2 strings without using built-in function.
Ans:
#include <stdio.h>
#include<string.h>
void main()
{
char s1[100] = "Welcome to ", s2[ ] = "C programming";
int length, j;
length = 0;
while (s1[length] != '\0')
length++;
for (j = 0; s2[j] != '\0'; j++)
{
s1[length] = s2[j];
length++;
}
s1[length] = '\0';
printf("After concatenation: ");
puts(s1);
}

b) Define String. Explain any 4 string manipulation function with suitable example.
Ans:
A string is a sequence of characters enclosed between double quotes.
i) strlen: This string function is basically used for the purpose of computing the length of string.
Syntax: strlen(str);
Example:
#include<stdio.h>
void main()
{
char str[10]= “COMPUTER”;
int len = strlen(str);
printf(“The length of string is = %d”,len);
}
ii) strupr: This string function is used to convert the string to uppercase.
Syntax: strupr(str);
Example:
#include<stdio.h>
void main()
{
char str[10]= “computer”;
printf(“The uppercase of string is = %s”,strupr(str));
}
iii) strlwr: This string function is used to convert the string to lowercase.
Syntax: strlwr(str);
Example:
#include<stdio.h>
void main()
{
char str[10]= “COMPUTER”;
printf(“The lowercase of string is = %s”,strlwr(str));
}
iv) strcat: This string function is used to concatenate two or more strings.
Syntax: strcat(str1,str2);
Example:
#include<stdio.h>
void main()
{
char str1[10]= “COMPUTER”;
char str2[10]= “SCIENCE”;
char str3[20];
str3=strcat(str1,str2);
printf(“The concatenated string is = %s”,str3);
}

c) Explain the difference between gets() and scanf() functions.


Ans:
gets() scanf()
It is used to read only string data It is used to read all types of data
It is not terminated when a white space is encountered It is terminated when a white space is encountered
It does not require a format specifier to read data It requires format specifier to read data
Syntax: gets(str); Syntax: scanf(“format specifier”,&v1,v2,….vn);
Example: Example:
#include<stdio.h> #include<stdio.h>
void main() Void main()
{ {
char str[10]; int a;
printf(“Enter your name\n”); printf(“Enter your marks\n”);
gets(str); scanf(“%d”,&a);
printf(“You entered: %s”,str); printf(“Your marks is = %d”,a);
} }
8. a) Develop a C program to find the largest of three numbers using pointer.
Ans:
#include <stdio.h>
void main()
{
int num1, num2, num3;
int *p1, *p2, *p3;
printf("Enter First Number: ");
scanf("%d",&num1);
printf("Enter Second Number: ");
scanf("%d",&num2);
printf("Enter Third Number: ");
scanf("%d",&num3);
p1 = &num1;
p2 = &num2;
p3 = &num3;
if(*p1 > *p2)
{
if(*p1 > *p3)
printf("%d is the largest number", *p1);
else
printf("%d is the largest number", *p3);
}
else
{
if(*p2 > *p3)
printf("%d is the largest number", *p2);
else
printf("%d is the largest number", *p3);
}
}

b) Define Pointer. Explain pointer variable declaration and initialization with suitable example.
Ans:
A pointer is a special variable which stores the address of another variable.
Declaration  Syntax  datatype *pointer_name;
Initialization  Syntax  pointer_name = &variable_name;
Example:
#include< stdio.h>
void main()
{
int a=22,*p ;
float b=2.25,*q ;
p=&a ;
q=&b ;
printf( “\n value of a = %d”,*p) ;
printf( “\n value of b = %d”,*q) ;
}
c) Explain the difference between a null pointer and a void pointer.
Ans:
Null pointer Void pointer
It does not point to any address of any type. It can point to any address of any type.
Null pointer are created using the NULL keyword Void pointers are created using the void keyword in
with assignment operator. the place where the datatype is placed.
It does not hold any address It can hold address of any datatype
It is faster compared to void pointer It is slower compared to null pointer
It is a bad programming approach It increases the flexibility of program
It has nothing to do with type casting It excludes programmers from type casting a pointer
repeatedly.
Syntax: datatype *pointer_name = NULL; Syntax: void *pointer_name;
Example: Example:
#include<stdio.h> #include<stdio.h>
void main() void main()
{ {
printf(“C Programming”); int a = 10;
int *p=NULL; void *ptr = &a;
printf(“The value of pointer is: %d”,p); printf("%d", *(int *)ptr);
} }

9. a) Discuss the general syntax of structure variable declaration of structure to store book information.
Ans:
After defining a structure format we must declare variables of that type. A Structure variable
declaration is similar to the declaration of variables of any other data types.
It includes the following elements.
1) The keyword struct.
2) The structure tag name.
3) List of variable names separated by commas.
4) A terminating semicolon.
For example: syntax
struct book_bank book1, book2, book3;
It declares book1, book2 and book3 as variables of type struct book_bank.
Example:
struct book_bank
{
char title[20];
char author[15];
int pages;
float price;
}book1, book2, book3;
b) Differentiate between structure and union.
Ans:
Si. No. Sturcture Union
1 Structures is a user-defined data type Union is a special data type available
available in C that allows to combining in C that allows storing different data
of data items of different kinds. types in the same memory location.
2 It allocates memory equal to sum of It allocates piece of memory that is
memory allocated to its each individual Large enough to hold the Largest
member. variable of type in union.
3 Each member have their own memory One block is used by all the members
space of union
4 Structure can not be implemented in Union is the Best environment where
shared memory memory is shared.
5 It has less Ambiguity As memory is shared, Ambiguity is
more in union.
6 Self referential structure can be Self referential union can not be
implemented in data structure. implemented.
7 All members of structure can be Only one member is accessed at a time.
accessed at a time
8 Size of structure is equal to the sum of Size of union is equal to the size of the
the size of member variables. large sized member variable.

9 Syntax: Syntax:
struct [structure name] union [union name]
{ {
member definition; member definition;
member definition; member definition;
... ...
member definition; member definition;
}; };
10 Example structure declaration: Example union declaration:
struct sVALUE union uVALUE
{ {
int ival; int ival;
float fval; float fval;
char *ptr; char *ptr;
}s; }u;
Here size of struct is 8 Bytes. Here size of union is 4 Bytes.

c) Write a program to write employees details in a file called employee.txt. Then read the record of the
nth employee and calculate his salary.
Ans:
Answer - - - - -will - - - - be - - - done - - - later
10. a) Discuss the different modes of operation on files with suitable example.
Ans:
Mode Description
r Opens a file in read mode
w Opens or creates a text file in write mode
a Opens a file in append mode
r+ Opens a file in both read and write mode
w+ Opens a file in both read and write mode
a+ Opens a file in both read and write mode
Example:
Program to read and write data to a file.
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp;
char ch;
fp = fopen("hello.txt", "w");
printf("Enter data");
while( (ch = getchar()) != EOF)
putc(ch,fp);
fclose(fp);
fp = fopen("hello.txt", "r");
while( (ch = getc(fp)! = EOF)
printf("%c",ch);
fclose(fp);
}

b) Differentiate between gets() and fgets().


Ans:
gets() fgets()
It is used to read string from the standard input device It is implemented in file related programs and used to
until newline character not found. read string till newline character not found.
Syntax: gets(str); Syntax: fgets(char *str, int n, FILE *stream);
Example: Example:
#include<stdio.h> #include<stdio.h>
void main() void main()
{ {
char name[20]; FILE *fp;
gets(name); char name[20];
printf(“\nYou Entered: %s”,name); fp = fopen(“filename”,“r”);
} fgets(name,20,stdin);
printf(“You entered: %s\n”, name);
fclose(fp);
}
c) Implement structures to read, write and compute average- marks of the students, list the students
scoring above and below the average marks for a class of N students.
Ans:
#include<stdio.h>
struct student
{
int marks;
}st[10];
void main()
{
int i,n;
float total=0,avgmarks;
printf("\nEnter the number of students in class(<=10):");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nEnter student %d marks :",i+1);
scanf("%d",&st[i].marks);
}
for(i=0;i<n;i++)
total = total + st[i].marks;
avgmarks=total/n;
printf("\nAverage marks = %.2f",avgmarks);
for(i=0;i<n;i++)
{
if(st[i].marks>=avgmarks)
printf("\n student %d marks = %d above average",i+1,st[i].marks);
else
printf("\n student %d marks = %d below average",i+1,st[i].marks);
}
}

You might also like