0% found this document useful (0 votes)
28 views9 pages

CT1 Set 1

This document outlines the Cycle Test I for the B.Tech Programming for Problem Solving course, detailing the course code, learning rationale, and outcomes. It includes a structured examination format with multiple-choice questions, short answer questions, and programming tasks, along with a key for grading. The test covers fundamental programming concepts, algorithms, data types, and C programming syntax.

Uploaded by

nimishparmar06
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)
28 views9 pages

CT1 Set 1

This document outlines the Cycle Test I for the B.Tech Programming for Problem Solving course, detailing the course code, learning rationale, and outcomes. It includes a structured examination format with multiple-choice questions, short answer questions, and programming tasks, along with a key for grading. The test covers fundamental programming concepts, algorithms, data types, and C programming syntax.

Uploaded by

nimishparmar06
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/ 9

CYCLE TEST – I Slot F , Batch 1

SET 1
Academic Year: 2022-2023 (EVEN Semester) OFF LINE

Program offered: B.Tech (All Branches) Year / Sem: I/ II


Max. Marks: 50 Time : 9.45 AM -11.30 AM
Date : 08-03-2023

Course Code and Title: 21CSS101J: Programming for Problem Solving

Course Learning Rationale (CLR):


CLR-1: Think and evolve with a logic to construct an algorithm and pseudo code that can be converted into a program.
CLR-2 : Utilize the appropriate operators and control statements to solve engineering problems
CLR-3 : Store and retrieve data in a single and multidimensional array
Course Learning Outcomes (CLO):
CLO-1: To solve problems through computer programming. Express the basic data types and variables in C
CLO-2 : To use appropriate data types in simple data processing applications. To create programs using the concept of
arrays.

Part A (10*1=10 Marks)


Sl.No Question CO PO BL Marks PI
CODE
1 Identify the Input or Output statement which is incorrect. 1 1 1 1

a) scanf("%d", age);
b) printf(“Enter the Value of a”);
c) printf("Enter two numbers A and B : \n");
d) scanf("%d", &height);

2 If ‘a’ is a float variable, then a=11/2 will return a value 1 2 1 1


a) 5.5
b) 5.500000
c) 5.000000
d) 5

3 Which of the following cannot be a variable name in C? 1 1 1 1


a) true
b) false
c) switch
d) export

4 Identify the operator is not belongs to relational operation 1 1 1 1


a) !=
b) ==
c) <=
d) ||
The operator “&” is used for____ 1 1 1 1
5 a) Logical AND
b) Logical OR
c) Bitwise OR
d) Bitwise AND

6 Find the output of the following code 2 2 1 1

#include <stdio.h>
int main()
{
int a=10,b=4;
if ((a>=8) && (b<=5))
printf("1");
else
printf("0");
return 0;
}
a) 8
b) 5
c) 1
d) 0
2 2 1 1
7 Find the output of the given code
#include <stdio.h>
int main()
{
if( 4 > 5 )
printf("hello..\n");
printf("world");
return 0;
}
a) hello
b) world
c) hello world
e) No Output
8 2 2 1 1
Find the output for the following code
#include<stdio.h>
int main( )
{
int x=1;
int y;
y=(x > 5 ? 3 : 4);
printf(“%d”, y);
return 0;
}
a) 4
b) 5
c) 3
d) 1
9. 2 2 1 1
Find the output for the following code
#include<stdio.h>
int main( )
{
int i=1,sum=0;
while (i<=3)
{
sum = sum + i; i++;
}
printf(“The sum of n Numbers is: %d”, sum);
return 0;
}
a) 6
b) 5
c) 3
d) 1
10 Find The Output Of The Following Code 2 2 1 1
#include<stdio.h>
void main()
{
int i=1, j=2, z;
printf("%d", i+++j);
}
a) 4
b) 3
c) 2
d) 1

Part B (4*5Marks=20 Marks)


Answer all questions

Sl.No Question CO PO BL Marks PI


Code
11 What are Algorithms? Write the Properties and Rules of 1 1 1 5
Writing an Algorithm
12 Write any five variable type with byte required, range and 1 1 1 5
format.
13 Write a C program to Check whether the given number is Odd. 2 2 2 5

14 What is pointer? How to Use Pointers? 2 2 1 5

Part C( 2*10=20 Marks)


Sl.No Question CO PO BL Marks PI
Code
15 a. Arun wants to print a document with "N" pages double-sided, where 1 2 2 10
two pages of data can be printed on one sheet of paper. Write a
program to tell him for printing N pages at least how many sheets of
paper he needs?
(OR)
15 b. What is a Variable? Give short note on variable scope. 1 2 2 10

16 a. Write a C Program to find the sum of positive numbers in the given 2 2 2 10


array.
(OR)
16 b. Develop a C program selects and prints the largest of the three 2 2 2 10
numbers using nested if....else statements.

Key

Part A

1.a
2.b
3.c
4.d
5.d
6.c
7.b
8.a
9.a
10.b

Part B

11.
What are Algorithms? Write the Properties and Rules of Writing an Algorithm
o A way to communicate about your problem/solution with others
o A possible way to solve a givenproblem
o A "formalization" of a method, that will beproved
o A mandatory first step before implementingasolution
 Properties of analgorithm
o Finite: The algorithm must eventuallyterminate
o Complete: Always give a solution when oneexists
o Correct (sound): Always give a correctsolution
 Rules of Writing anAlgorithm
o Beconsistent
o Have well Defined input andoutput
o Do not use any syntax of any specific programminglanguage

12.
Write any five variable type with byte required, range and format.

13.
Write a C program to Check whether the given number is Odd

#include<stdio.h>

int main()
{
int num;
printf("Enter a number\n");
scanf("%d",&num);

if(num % 2 == 0)
printf("The given number is not ODD\n");
else
printf("The given number is odd\n");

return 0;

Result :

Enter a number
21
The given number is odd

14. What is pointer? How to Use Pointers?


Pointer:

A pointer is nothing but a memory location where data is stored. A pointer is used to access the memory location. There are
various types of pointers such as a null pointer, wild pointer, void pointer and other types of pointers. Pointers can be used
with array and string to access elements more efficiently.

How to use pointer:

#include <stdio.h>

int main () {

int var = 20; /* actual variable declaration */


int *ip; /* pointer variable declaration */

ip = &var; /* store address of var in pointer variable*/

printf("Address of var variable: %x\n", &var );

/* address stored in pointer variable */


printf("Address stored in ip variable: %x\n", ip );

/* access the value using the pointer */


printf("Value of *ip variable: %d\n", *ip );

return 0;
}

Result :

Address of var variable: 43a11a4c


Address stored in ip variable: 43a11a4c
Value of *ip variable: 20

PART C

15.a.

Arun wants to print a document with "N" pages double-sided, where two pages of data can be printed on one sheet of
paper. Write a program to tell him for printing N pages at least how many sheets of paper he needs?

#include<stdio.h>

int main()
{
int n,m;
printf("Enter number of pages to be printed\n");
scanf("%d",&n);

if(n/2 != 0 )
m=n+1;
printf("The number of sheets required to print %d pages is %d\n",n,m/2);

return 0;

}
Result:
Enter number of pages to be printed
17
The number of sheets required to print 17 pages is 9

Enter number of pages to be printed


18
The number of sheets required to print 18 pages is 9

15.b

What is a Variable? Give short note on variable scope.

 Storage Class Specifiers tells the Compiler about thefollowing:


o Where to Store aVariable
o What is the Initial value of theVariable
o What is the Lifetime of aVariable
 Variable Scope: Area or block where the variables can be accessed
a) Automatic Variables
b) External Variables
c) Static Variables
d) Register variables

16.a
Write a C Program to find the sum of positive numbers in the given array.

#include<stdio.h>

int main()
{
//let's assume the maximum array size as 100.
//initialize sum as 0. Otherwise, it will take some garbage value.
int arr[100], size, i, sum = 0;

//Get size input from user


printf("Enter array size\n");
scanf("%d",&size);

//Get all elements using for loop and store it in array


printf("Enter array elements\n");
for(i = 0; i < size; i++)
scanf("%d",&arr[i]);

//add all elements to the variable sum.


for(i = 0; i < size; i++)
{
if(arr[i]>0)
sum = sum + arr[i]; // same as sum += arr[i];
}

//print the result


printf("Sum of the array = %d\n",sum);

return 0;
}

Result:

Enter array size


6
Enter array elements
0
-1
-5
4
3
0
Sum of the array = 7

Enter array size


3
Enter array elements
1
2
3
Sum of the array = 6

16.b

Develop a C program selects and prints the largest of the three numbers using nested if....else statements.

#include <stdio.h>

int main() {

double n1, n2, n3;

printf("Enter three numbers: \n");


scanf("%lf %lf %lf", &n1, &n2, &n3);

// outer if statement
if (n1 >= n2) {

// inner if...else
if (n1 >= n3)
printf("%.2lf is the largest number.n", n1);
else
printf("%.2lf is the largest number.\n", n3);
}

// outer else statement


else {

// inner if...else
if (n2 >= n3)
printf("%.2lf is the largest number.\n", n2);
else
printf("%.2lf is the largest number.\n", n3);
}

return 0;
}

Result:
Enter three numbers:
1
1.001
1.332
1.33 is the largest number.

You might also like