UTA003
UTA003
NOTE: Solve in order and new problem on new page. Assume any missing a rta. No
checking for cuttings or mess:. Give all details to claim full marks.
Example 1:
Input : 4 9 1 0 Output : 9
Example 2:
Input : 2 12 -3 9 :7-:3 0 Output : 33
Q4 Is there any difference between "while" and "do-while" loop. yes,
clearly mention the difference between these two loops with the t- Ip of
an example.
Q5 You are given two positive integers a and b as an input. Write a C 3+3
program to calculate ab with the help of loops. Draw the flowchart to
show the working cf the program.
Faculty: HS Pannu, Raman Goyal, Saif Nalband, Seemu Sharma, Simran Setia, Deep Mann,
Amrita Kaur, Vivek Sethi, Sujata Rani, Prateek Vishnoi
NOTE: Solve all the questions in order otherwise they will not be checked. Only use a blue pen. New
problem, new page. No partial credit for cuttings. Plan on the last page before attempting to avoid
cutting. Assume any missing data. Each question has 5 marks.
Q1. Write short notes on the following with a small example (i) switch case (ii) type conversion.
Q3. Draw the flowchart to input a positive integer and find the sum of digits. Carefully use the
conventions of the input box, process box, decision box and the directed edges.
Q4. Find all the syntax and logiscal errors in the given C language program. No explanation
_needed but just list the errors concisely in your answer.
#include<studio.h>
int main() {
int sum;
int k,i;
for(int i=1, i<=10, ++i);
{
sum=sum+k;
k++;
}
printf("The value of sum is %f', sum);
return 0
Q5. Write a program in C language to find if the year is a leap year or not. Below are the rules
for a year to qualify for a leap year.
(a) If the year is divisible by 4 then it is a leap year. For example, year 2024 is a leap year.
BUT
(b) If the year is divisible by 100 then it should also be divisible by 400. For example year 2000
is a leap year but year 2100 is not
Q6. Complete the following C program to find the second smallest number in the array. No need
to re-write the whole program, just write the missing piece.
#include<stdio.h>
int main(){
int n,i,A[] = {4, 34, 9, 1, -5, 2, 8, 11. 15.3}, x
return 0:
Q7. Anagrams are words or phrases that arc formed by rearranging the letters of another
word/phrase. For example, (i) tea and eat (ii) rope and epor.
Write a C program to check whether two input strings are anagrams or not.The input strings may
or may not be a dictionary word.