0% found this document useful (0 votes)
23 views4 pages

CT 1 - Solution

This document contains a class test for a Computer Engineering course. It includes 6 questions asking students to define terms like algorithms and flowcharts, explain type casting, list C operators, and implement programs for adding floats and dividing integers with float output. Examples are provided for each question to illustrate concepts like algorithms, type casting, printf/scanf functions, and code for arithmetic operations.

Uploaded by

zaltesahil94
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)
23 views4 pages

CT 1 - Solution

This document contains a class test for a Computer Engineering course. It includes 6 questions asking students to define terms like algorithms and flowcharts, explain type casting, list C operators, and implement programs for adding floats and dividing integers with float output. Examples are provided for each question to illustrate concepts like algorithms, type casting, printf/scanf functions, and code for arithmetic operations.

Uploaded by

zaltesahil94
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/ 4

JES’s

S.N.D. Polytechnic, Yeola. Class Test


Academic Year- 2023-24
Programme: Computer Engineering Course: PIC Course Code: 312303

Semester: Second Name of Faculty: Prof. Chouhan P.B

20 Marks
Q 1 Define the following terms (With Examples):-
a. Algorithm
 A sequential solution to any problem written in human language is called as
algorithm.
 A process that should be followed for solving a specific problem is called
algorithm.
 A step by step problem solving procedure for solving a problem in a finite
number of steps is called algorithm.
 The algorithm is defined as the finite set of steps, which provide a chain of
actions for solving a definite nature of problem.
 Algorithm MULTIPLICATION(Example)
1. START
2. INPUT first number into variable A
3. INPUT second number into variable B
4. COMPUTE C = A * B
5. DISPLAY C
6. END
b. Flowchart
 Flowchart represents the solution of a given problem graphically. Pictorial
representation of the logical steps is a flowchart. It is a diagrammatic
representation that shows flow of execution of a program.
 Eg:- Flowchart for multiplication

c. Variables
 Variable is an entity whose value can be changed during execution of a
program. Actually, the variable names are the names given to locations in
memory (primary memory – which is most commonly RAM).
 Eg. int a=4; // here variable name is ‘a’ and 4 is the constant/value.
float b=8.9879; // here variable is ‘b’ and 8.9879 is constant/value.
JES’s
S.N.D. Polytechnic, Yeola. Class Test
Academic Year- 2023-24
Programme: Computer Engineering Course: PIC Course Code: 312303

Semester: Second Name of Faculty: Prof. Chouhan P.B

Q 2Explain the concept of type casting/type conversion with its types and give one
example of each.
 In some situations, programmer needs to convert data type of a variable, a
value or an expression temporarily. Process of doing so is called
typecasting. This can be achieved by using following syntax.(new-data-
type)variable/expression/value
 Type of type casting
 Implicit Type Casting.(Automatic)
 Implicit type casting in C is used to convert the data type of
any variable without using the actual value that the variable
holds. It performs the conversions without altering any of the
values which are stored in the data variable. Conversion of
lower data type to higher data type will occur automatically.
 Explicit Type Casting.(Manual)
 Example:(Implicit example)
int a = 15, b = 2;
float div;
div = a / b;
printf("The result is %f\n", div);
 Example:(Explicit example)
int a,b;
float avg;
printf(“Enter two numbers: ”);
scanf(“%d%d”,&a,&b);
avg=(float)(a+b)/2;

Q 3 What different operators are available in C, List them down with


example.(Explain each)
Arithmetic operators
- Relational operators
- Logical operators
- Assignment operators
- Increment and decrement operators
- Conditional operators
- Bitwise operators
JES’s
S.N.D. Polytechnic, Yeola. Class Test
Academic Year- 2023-24
Programme: Computer Engineering Course: PIC Course Code: 312303

Semester: Second Name of Faculty: Prof. Chouhan P.B

- Special operators
Q 4 State the use of printf() and scanf() with suitable example.
Printf()
 We use printf( ) function for displaying formatted output. (printf stands for
print-formatted)
 Basic syntax of printf( ) function is given below.
int printf(const char *format [, argument, … ]);
 This function converts, formats and displays its arguments on the standard
output. It returns number of characters displayed.
 The format string can contain following types of objects
– Ordinary characters (they are directly sent to output as they are)
– Escape sequences.
– Control sequence or conversion specification (they are replaced
sequentially by arguments specified after the formats).
 Example 1:
printf(“Hello”); printf(“Everybody”);
Scanf():-
 We use scanf( ) function for receiving formatted input. (scanf stands for scan-
formatted).
 Basic syntax of scanf( ) function is given below.
int scanf(const char *format [, address, … ]);
 This function scans input (one character at a time), formats each field
according to corresponding format specifier passed in format string and
stores the resulting value at the given address (in the specified variable).
 Example 1:
int a;
printf(“Enter a value: ”);
scanf(“%d”,&a);
JES’s
S.N.D. Polytechnic, Yeola. Class Test
Academic Year- 2023-24
Programme: Computer Engineering Course: PIC Course Code: 312303

Semester: Second Name of Faculty: Prof. Chouhan P.B

 /* Here a common mistake is – absence of & symbol. This error is not


identified by compiler and therefore very much problematic. We should
carefully avoid the error */
printf(“You have entered value of a as %d”,a);
Q 5 Implement a C program for addition of two Float numbers along with its
flowchart and algorithm.
 #include<stdio.h>
void main()
{
float a=6.4,b=4.9;
float c;
clrscr();
c=a+b;
printf("The sum of two float numbers is : %f",c);
getch();
}
Q 6 Implement a C program for Division of two integers.(the output should be a
floating point value\ float value)
 #include<stdio.h>
void main()
{
int first=6,second=68;
float sum;
clrscr();
sum=first+second;
printf("The sum of two float numbers is : %f",sum);
getch();
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy