You are on page 1of 5

You may use illustrations and diagrams to enhance the

explanations.

Question 1:

(a) Write a simple program to find the size of different basic data types in C.

Ans:- #include<stdio.h>

#include<conio.h>

void main()

clrscr();

printf("size of int =%d",sizeof(int));

printf("\nsize of float =%d",sizeof(float));

printf("\nsize of char =%d",sizeof(char));

getch();

(b) Write a program in C for showing working of different logical operator in C.

Your program should guide users with proper message/menu on the console.

# include<stdio.h>

void main()
{
menu();
}

menu()
{
int i, a =0,b=1,c;
printf(“Enter the operation need to be performed” \n);
printf(“Enter 1 to perform And operation” \n);
printf(“Enter 2 to perform OR operation” \n” \n);
printf(“Enter 3 to perform NOT operation” \n);
printf(“Enter 4 to exit” \n);
scanf(“%d”, i);
if (i==1)
c=and(a,b);
else if(i==2)
c=OR(a,b);
else if(i==3)
c=not(a,b);
else if(i==4)
exit(0);
printf (“The result is %d”, c);
menu();
}

and(a,b)
{
return (a&&b);
}

or()
{
return (a||b);
}

not(a)
{
return (!a);
}
}

(c) Write a function to find the area of a triangle whose length of three sides is
given

#include<stdio.h>

02 #include<math.h>

03 int main()

04 {

05 float a,b,c,s,area;

06 printf("\n Enter the three sides of triangle\n");

07 scanf("%f%f%f",&a,&b,&c);
08 s=(a+b+c)/2;

09 area=sqrt(s*(s-a)*(s-b)*(s-c));

10 printf("\n area of the triangle is %f", area);

11 return 0;

12 }

Question 2:

(a) Write a C program to print the following triangle:

***

*****

*******

*********

************

(b) Write a C program to read the internal test marks of 25 students in a class
and

show the number of students who have scored more than 50% in the test.

Make necessary assumptions.

Question 3:
(a) What is calling by reference? How it is different from call by value?
Write a C function to swap two given numbers using call by

reference mechanism.

(b) Write a C program for addition of two 3×3 matrices.

(c) Write a C program for finding GCD of two given numbers.

Question 4:

(a) Write C programme for followings:

i) Counting the number of words in a given string

ii) Concatenating two given strings

(b) What is a pointer? Explain pointer arithmetic with example. Also explain use of
malloc function in C programming with an example

Question 5:

(a) Explain recursion. Also write a C program for Tower of Hanoi problem with

a example of 4 disks .

(b) Write a C program using structure to find students grades in a class.


Make the necessary assumptions.

You might also like