✅ 1. C program that uses comments to display the output using variables
✅ 2. C program that uses both constants and variables
✅ 3. C program using different data types
✅ 4. Program using putchar() and puts()
✅ 5. Program using getchar(), getch(), getche()
getch() and getche() work only in <conio.h> and Turbo C/Some compilers.
✅ 6. Program demonstrating compound assignment operators
✅ 7. Program to find remainder of two numbers
✅ 8. Program using Strings
✅ 9. Program to check Odd or Even
✅ 10. Program to print average of 3 numbers
🧪 Lab Exercises (5 Questions)
Q1. Print your name and age
Q2. Input age and print it
Q3. Input two numbers and print sum
Q4. Print formatted table using escape sequences
(Already provided; repeating clean version)
Q5. Input marks of 3 subjects and print total
⚡ Logical Operators Set
Q1. Gym Entry Condition (OR + NOT)
Q2. Largest among 3 numbers using &&
Q3. Program using ++ and --
Q4. Program using relational operators
Q5. Difference between = and ==
Assignment operator (=)
Used to assign a value to a variable
Example: x = 10;
Equal to operator (==)
Used to compare two values
Example: if (x == 10)
1. Area of Rectangle
(a) Using hard coded input
#include <stdio.h>
int main() {
int length = 10, width = 5; // Hard coded values
int area = length * width;
printf("Length = %d\n", length);
printf("Width = %d\n", width);
printf("Area of Rectangle = %d\n", area);
return 0;
}
(b) Using user input
#include <stdio.h>
int main() {
int length, width, area;
printf("Enter length of rectangle: ");
scanf("%d", &length);
printf("Enter width of rectangle: ");
scanf("%d", &width);
area = length * width;
printf("Area of Rectangle = %d\n", area);
return 0;
}
2. Area of Circle and Volume of Cylinder
#include <stdio.h>
#define PI 3.1416
int main() {
float radius, height, area, volume;
printf("Enter radius of circle: ");
scanf("%f", &radius);
area = PI * radius * radius;
printf("Area of Circle = %.2f\n", area);
printf("Enter height of cylinder: ");
scanf("%f", &height);
volume = PI * radius * radius * height;
printf("Volume of Cylinder = %.2f\n", volume);
return 0;
}
3. Convert Celsius to Fahrenheit
#include <stdio.h>
int main() {
float celsius, fahrenheit;
printf("Enter temperature in Celsius: ");
scanf("%f", &celsius);
fahrenheit = (celsius * 9 / 5) + 32;
printf("Temperature in Fahrenheit = %.2f\n", fahrenheit);
return 0;
}
#include <stdio.h>
int main() { int a, b, remainder; printf("Enter two integers:\n"); scanf("%d %d", &a, &b); remainder = a % b; printf("The remainder when %d is divided by %d is %d\n", a, b, remainder); return 0; }Assignment Problems (C Programming Basics)
Q1: Personal Information
printf().%s, %d, %c.Q2: Circle Area (Using Constant)
Area = PI * radius * radiusprintf().Q3: Simple Calculator
a and b.Addition
Subtraction
Multiplication
- Division👉 Example output:
Q4: Student Marks
%f and %.2f for decimals.Q5: Variable Update
age = 15.🧩 1. Check if a number is positive or negative
Explanation:
Uses relational operators>,<, and==.
🧩 2. Check if a number is even or odd
Explanation:
Uses%modulus operator and==.
🧩 3. Check if a number is divisible by both 3 and 5
Explanation:
Uses logical AND (&&).
🧩 4. Check if a number lies between 10 and 50
Explanation:
Relational operators>=,<=and logical AND (&&).
🧩 5. Find the greatest of two numbers
Explanation:
Compares using relational operators>,<.
🧩 6. Check if a person is eligible to vote
Explanation:
Simple>=relational comparison.
🧩 7. Check if a character is a vowel
Explanation:
Uses logical OR (||) with multiple relational checks.
🧩 8. Check if a year is a leap year
Explanation:
Combination of AND (&&) and OR (||) logical operators.
🧩 9. Check eligibility for admission
Explanation:
Checks range using relational and logical operators.
🧩 10. Determine grade based on percentage
Explanation:
Uses multiple if-else-if and relational comparisons.

Group Wise Project
📘 Objective:
Write a C program that:
Takes student details (name, roll number, and marks of 3 subjects) using
scanf().Calculates total marks and average using arithmetic operators.
Uses if–else statements to determine the student’s grade.
Displays results using
printf()and format specifiers.Includes proper use of escape sequences for clean formatting.
Prog 1:
#include<stdio.h>
int main(){
printf("Hello ");
printf("world\n");
int a = 1;
// Loops are used to repeat similar part of a code snippet efficiently
// (
// printf("%d\n", a);
// a++;) =---> 100 times
return 0;
}
Prog 2:
#include<stdio.h>
int main(){
int a;
scanf("%d", &a);
while(a<10){
// a = 11;
// while(a>10){ ---> These two lines will lead to an infinite loop
printf("%d\n", a);
a++;
}
return 0;
}
Prog 3:
#include<stdio.h>
int main(){
int i = 5;
while(i<=20){
if (i >= 10){
printf("The value of i is %d\n", i);
}
i++; // i = i + 1;
}
return 0;
}
Prog 4:
#include<stdio.h>
int main(){
int i = 5;
printf("The value after i++ is %d\n", ++i);
i++; // --->
++i; // --->
printf("The value of i is %d\n", i);
i+=10; //--> Increments i by 10
printf("The value of i is %d\n", i);
return 0;
}
Prog 5:
#include<stdio.h>
int main(){
int i = 0;
do{
printf("The value of i is %d\n", i);
i++;
}while(i <10);
return 0;
}
Prog 6:
#include<stdio.h>
int main(){
int i=0;
int n;
printf("Enter the value of n\n");
scanf("%d", &n);
do{
printf("The number is %d \n",i+1);
i++;
}while(i<n);
return 0;
}
Prog 7:
#include<stdio.h>
#include<conio.h>
main()
{
int x;
do
{
printf("Enter zero to quit");
scanf("%d",&x);
}while(x!=0);
}
Prog 8:
#include<stdio.h>
#include<conio.h>
main()
{
char e;
int p;
do
{
printf("\nEnter your email");
scanf("%c",&e);
printf("\nEnter your passwrod");
scanf("%d",&p);
}while(e!='r' && p!=5);
}
Prog 9:
The Infinite Loop
A loop becomes an infinite loop if a condition never becomes false. The for loop is traditionally used for this purpose. Since none of the three expressions that form the 'for' loop are required, you can make an endless loop by leaving the conditional expression empty.
#include <stdio.h> int main () { for( ; ; ) { printf("This loop will run forever.\n"); } return 0; }
When the conditional expression is absent, it is assumed to be true. You may have an initialization and increment expression, but C programmers more commonly use the for(;;) construct to signify an infinite loop.
NOTE − You can terminate an infinite loop by pressing Ctrl + C keys.
Prog 10:
#include<stdio.h>
int main()
{
int i = 0;
while(i<10)
{
printf("hellohyd:%d\n",i);
i++;
}
printf("Control reached here");
return 0;
}
MORE PRACTICES ON LOOP
Perform the given programs on Dev C++ and execute to check the output. Write down the Program and Output in your register too.
Note: Write down the program in your register with their outputs.
Prog 1:
Prog 2:
Prog 3:
Prog 4:
Prog 5:
Prog 6:
Prog 7:
Prog 8:
Prog 9:
Prog 10:
Prog 11:



No comments:
Post a Comment