0% found this document useful (0 votes)
56 views

2019 CE143 First Internal Solution

This document contains instructions for a computer concepts and programming exam. It includes 4 questions with multiple parts. Question 1 has true/false statements, rewriting code using conditional operators, and identifying correct/incorrect code. Question 2 asks to explain concepts like flowcharts, differences between compilers and interpreters, I/O functions, evaluating expressions, the goto statement, and loop types. Question 3 asks to write programs to determine if a point lies inside/outside a circle based on radius and coordinates, check triangle types based on side lengths, and calculate length and digit sum of an input number.

Uploaded by

Dhruv Soni
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)
56 views

2019 CE143 First Internal Solution

This document contains instructions for a computer concepts and programming exam. It includes 4 questions with multiple parts. Question 1 has true/false statements, rewriting code using conditional operators, and identifying correct/incorrect code. Question 2 asks to explain concepts like flowcharts, differences between compilers and interpreters, I/O functions, evaluating expressions, the goto statement, and loop types. Question 3 asks to write programs to determine if a point lies inside/outside a circle based on radius and coordinates, check triangle types based on side lengths, and calculate length and digit sum of an input number.

Uploaded by

Dhruv Soni
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/ 3

Candidate seat No: _______________

Charotar University of Science and Technology [CHARUSAT]


Faculty of Technology and Engineering
U & P U Patel Department of Computer Engineering
Subject: CE143 Computer Concepts & Programming
First Internal Exam

Semester: 1st SEM B. Tech. (CE/IT/EC/CSE) Maximum Marks: 30


Date: 10/09/2019 (Tuesday) Time: 11:10 a.m. to 12:10 p.m.
Instructions:
(i) Attempt all the questions.
(ii) Figures to the right indicate full marks.
(iii) Make suitable assumptions and draw neat figures wherever if required.

Q-1 Do as directed.
(1) State whether the following statements are True or False. [04]
1. Header files are preprocessed by the preprocessor and library files are linked to the
program by a linker.
True
2. Constants also have a data type like variables.
True
3. Bitwise operators can be used with float data types.
False
4. The default case is required in the switch statements.
False
(2) Rewrite the following program using conditional operators. [02]
#include<stdio.h>
void main()
{
float sal;
printf("Enter the salary: "); scanf("%f",&sal);
if(sal<=40000 && sal>=25000)
printf("Manager");
else
{
if(sal<25000&&sal>=15000)
printf("Accountant");
else if(sal<15000 && sal>=5000)
printf("Clerk");
else
printf("Invalid salary");
}
}

Answer:
#include<stdio.h>
void main()
{
float sal;
printf("Enter the salary: ");
scanf("%f",&sal);
Page 1 of 3 [P.T.O]
(sal<=40000 && sal>=25000)?printf("Manager"):
(sal<25000&&sal>=15000)?printf("Accountant"):
(sal<15000 && sal>=5000)?printf("Clerk"):printf("Invalid salary ");
}
(3) Find out the output of the following code if it is correct or find error if the code is incorrect. [02]
(1) #include<stdio.h> (2) #include<stdio.h>
void main() void main()
{ { int choice=65;
int x=20,y=3; switch(choice)
if(x!=20&&printf("\nx+y=%d",x+y)) {
printf("Logical&& Excecuted"); case 65: printf("65"); break;
case 'A': printf("A"); break;
if(x!=20 & printf("\nx*y=%d",x*y)) default: printf("Default"); break;
printf("Bitwise & Excecuted"); }
} }

Error:
OUTPUT:
duplicate case value
x*y = 60
Program generates error as duplicate
case value is not allowed 65 and ‘A’

(4) Mention whether the following are VALID/INVALID variable names. [02]
(i) #mean INVALID (ii) int_a VALID
(iii) hello. INVALID (iv) FLOAT VALID
Q-2 Answer the following question. (Any 5) [10]
(1) Given the length and breadth of a rectangle. Draw the flowchart to find whether the area of
the rectangle is greater than its Perimeter or not. Area of rectangle = length * breadth.
Perimeter of rectangle = 2 * (length + breadth)
(2) Mention any two difference between compiler and interpreter.
(3) Explain getchar() and putchar() functions of <stdio.h>
(4) Evaluate the following expression step by step in detail.
(9/3 + 7%2) * (8-3/7 / (4+3))
First Pass:
Step 1: (9/3 + 7%2) * (8-3/7 / 7)
Step 2: (3 + 7%2) * (8-3/7 / 7)
Step 3: (3 + 1) * (8-3/7 / 7)
Step 4: 4 * (8-3/7 / 7)
Step 5: 4 * (8-0 / 7)
Step 6: 4 * (8-0)
Step 7: 4 * 8
Second Pass:
Step 8: 32

Page 2 of 2
(5) Demonstrate the use of goto statement with example.
(6) Identify whether the following code is an entry controlled loop or exit controlled loop.
Justify your answer.
#include <stdio.h>
void main()
{
double number, sum = 0;
do
{
printf("Enter a number: ");
scanf("%lf", &number);
sum += number;
}
while(number != 0.0);
printf("Sum = %.2lf",sum);
}
Answer:
Exit controlled loop
Justification: Here first the loop will be executed and then the condition is checked at
the end of the loop. Do..while is an example of exit controlled loop.
Q-3 Write down following programs in C. (Any two) [10]
(1) The center of the circle is at point (0, 0). If the Radius of the circle and coordinates of a
point (x, y) are entered through the keyboard, write a program which will determine whether
a point (x, y) lies inside the circle, on the circle or outside the circle. Equation of the circle is
x2 + y2 = r2 . Use nested if..else statement.
(2) If the three sides of a triangle are entered through the keyboard, write a program to check
whether the triangle is isosceles, equilateral or scalene using else…if ladder.
 An isosceles triangle is a triangle with (at least) two equal sides.
 An equilateral triangle is a triangle in which all three sides are equal.
 A scalene triangle is a triangle that has three unequal sides.

(3) If an n-digit number is entered through the keyboard, write a program to find the length of
the number and calculate sum of its digit. For example if 5436 is entered through the
keyboard then length of the number is 4 and sum of its digit is 5+4+3+6 = 18. Use any
looping concept.

*****

Page 3 of 2

You might also like