C-Programming-Fundamentals-A-Beginners-Guide ppt
C-Programming-Fundamentals-A-Beginners-Guide ppt
33200124008
2025
BASIC PROGRAMING
C Programming
Fundamentals: A
Beginner's Guide
Welcome to this introductory guide on C programming. This
presentation will cover essential concepts and practical examples
that will help you get started with C.
"Q.Wap to accept radius and height of a cone and find its volume.
INPUT:
#include <stdio.h>
int main() {
// Declare variables for radius, height, and volume
float radius, height, volume;
const float PI = 3.14159;
// Prompt the user to enter the radius and height
printf("Enter the radius of the cone: ");
scanf("%f", &radius);
printf("Enter the height of the cone: ");
scanf("%f", &height);
// Calculate the volume of the cone
volume = (1.0 / 3.0) * PI * radius * radius * height;
// Display the result
printf("The volume of the cone is: %.2f\n", volume);
return 0;
}
OUTPUT:
Q.Wap to accept two number from the user and find the smaller number.
INPUT:
#include <stdio.h>
int main() {
// Declare variables to store the two numbers
int num1, num2, smaller;
// Prompt the user to enter the first number
printf("Enter the first number: ");
scanf("%d", &num1);
// Prompt the user to enter the second number
printf("Enter the second number: ");
scanf("%d", &num2);
// Use the ternary operator to find the smaller number
smaller = (num1 < num2) ? num1 : num2;
// Display the result
printf("The smaller number is: %d\n", smaller);
return 0;
}
OUTPUT:
Q.find out the value of x and y. z=--y+y+++--y+++y+y--; where y=5
INPUT:
#include <stdio.h>
int main() {
int y = 5;
int z = --y + y++ + --y + ++y + y--;
printf("y = %d\n", y);
printf("z = %d\n", z);
return 0;
}
Declaratio
n
I have not copied the contents of slide from external sources. Figures used from external sources have been
acknowledged properly. Thank you.