[go: up one dir, main page]

0% found this document useful (0 votes)
16 views3 pages

SP Assignment - 01

The document outlines a series of programming exercises in C, categorized into sections such as Input and Operators, Conditional Statements, Loops, Arrays, Functions, Strings, and Structures. Each section contains specific tasks, such as using scanf() for input, implementing conditional logic, creating loops, working with arrays, defining functions, manipulating strings, and defining structures. The exercises aim to enhance understanding of fundamental programming concepts and practices in C.

Uploaded by

Edu yt
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)
16 views3 pages

SP Assignment - 01

The document outlines a series of programming exercises in C, categorized into sections such as Input and Operators, Conditional Statements, Loops, Arrays, Functions, Strings, and Structures. Each section contains specific tasks, such as using scanf() for input, implementing conditional logic, creating loops, working with arrays, defining functions, manipulating strings, and defining structures. The exercises aim to enhance understanding of fundamental programming concepts and practices in C.

Uploaded by

Edu yt
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

1.

Input and Operators

1.​ What is scanf()? How is it used in C programming?​

2.​ Write a program to input two integers from the user and display their sum, difference,
product, quotient, and remainder.​

3.​ Write a program to input a number and check if it is even or odd using the modulo
operator.​

4.​ Write a program to take the radius of a circle as input and calculate its area and
circumference.​

5.​ Write a program to input two numbers and display which one is larger using the ternary
operator.​

2. Conditional Statements (if-else, switch)

6.​ Write a program to find the largest/smallest of three numbers.​

7.​ Write a program to input a number and check whether it is positive, negative, or zero.​

8.​ Write a program to check if a character is a vowel or consonant.​

9.​ Write a program to input the age of a person and check if they are eligible to vote (age ≥
18).​

10.​Write a program to determine whether a year is a leap year.​

11.​Write a program to input marks and display the corresponding grade using if-else:​

○​ 80 and above: A+​

○​ 70–79: A​

○​ 60–69: A–​

○​ 50–59: B​
○​ Below 50: F​

12.​Write a program to create a simple calculator using a switch case. The user will enter
two numbers and choose an operator (+, –, *, /).​

3. Loops (for, while, do-while)

13.​Write a program to print all numbers from 1 to 100 using a for loop.​

14.​Write a program to print the multiplication table of 5 using a loop.​

15.​Write a program to print the factorial of a number using a loop (not recursion).​

16.​Write a program to print the Fibonacci series using a loop.​

4. Arrays

17.​Write a program to input 6 integers into an array and display them.​

18.​Write a program to find the largest element in the array.​

19.​Write a program to input 10 numbers into an array and count how many of them are
even.​

20.​Write a program to input marks of 5 subjects into an array, then calculate and display the
total and average marks.​

5. Functions (without recursion)

21.​Write a program to define a function that takes two numbers and returns their sum. Call
the function from main().​

22.​Write a program to define a function that converts Celsius to Fahrenheit.​


23.​Write a program to input three numbers and use a function to find and return the
smallest number.​

24.​Write a program to define a function that takes an integer and returns the sum of its
digits.​

25.​Write a function to swap 2 numbers.​

26.​Write a program to pass an array to a function to find and return the squared values of all
the elements in the array.​

6. Strings

27.​Write a program to input a string and count how many characters it contains.​

28.​Write a program to check whether a string is a palindrome or not (e.g., “madam”).​

7. Structure

29.​Write a program to define a structure called Employee with fields: name (string), id (int),
and salary (float). Input data for one employee and display it.

You might also like