//find out area of a circle
#include <stdio.h>
int main() {
int radius;
int area;
float pi = 13.4;
printf("Enter radius");
scanf("%d", &radius);
area = pi*radius*radius;
printf("area of the circle is%d", area);
return 0;
//Area of a square
#include <stdio.h>
int main() {
int side;
int area;
printf("Enter the side");
scanf("%d", &side);
area = side*side;
printf("%d", area);
return 0;
}
//Perimeter of rectangle
Int Prectangle;
Int length;
Int width;
Printf(
int main() {
int prectangle;
int length;
int width;
printf("Enter length");
scanf("%d", &length);
printf("Enter width");
scanf("%d", &width);
prectangle = length + width * 2;
printf("perimeter of rectangle is: %d", prectangle);
//take a number from user & output its cube(n*n*n) (not executing, doesn’t give any output)
#include <stdio.h>
int main() {
int number;
printf("Enter a number");
scanf("%d", &number);
number = number*number*number;
printf("\ncube of the number: %d", number);
return 0
};
//a program to print average of 3 numbers
#include <stdio.h>
int main() {
int number1;
int number2;
int number3;
int avg;
printf("Enter number 1: \nEnter number 2:\nEnter number 3");
scanf("%d%d%d", &number1, &number2, &number3);
avg = number1 + number2 + number/300
printf("Average of the numbers: %d", avg);
return 0;
//Char key = ‘a’
#include <stdio.h>
int main() {
char key;
printf("Enter a key: ");
scanf("%c", &key);
if (key=='a' || key=='A')
printf("Pass");
else
printf("fail");
return 0;
}
//individual number should not be negative
int main(){
int a;
int b;
int c;
int d;
printf("Enter 1st number: ");
scanf("%d", &a);
printf("Enter 2nd number: ");
scanf("%d", &b);
printf("Enter 3rd number: ");
scanf("%d", &c);
printf("Enter 4th number: ");
scanf("%d", &d);
if (a>=0 && b>=0 && c>=0 && d>=0)
printf("\nnumbers are positive: ");
if (a%2==0 && b%2==0 && c%2==0 && d%2==0)
printf("\nNumbers are even:");
else
printf("\nWrong input");
printf("Please check and enter a postive positive number");
return 0;
//Atm
int main() {
// atm
int amount;
int notes2000, notes500, notes200, notes100;
printf("Enter amount: ");
scanf("%d", &amount);
notes2000 = amount/2000;
amount -= notes2000*2000;
notes500 = amount/500;
amount-= notes500*500;
notes200 = amount/200;
amount -= notes200*200;
notes100 = amount/100;
amount -= notes100*100;
printf("\nNo. of 2000 notes are: %d",notes200);
printf("\nNo. of 500 notes are: %d", notes500);
printf("\nNo. of 200 notes are: %d", notes200);
printf("\nNo. of 100 notes are: %d", notes100);
return 0;
#include <stdio.h>
int main()
int Maths;
int Science;
int Hindi;
int percentage;
printf("Enter your maths marks: ");
scanf("%d", &Maths);
printf("Enter your Science marks: ");
scanf("%d", &Science);
printf("Enter your hindi marks: ");
scanf("%d", &Hindi);
percentage = (Maths+Science+Hindi)/300*100;
if (percentage<33)
printf("Fail");
if (percentage>=33 && percentage<=45)
printf("3rd division");
if (percentage>45 && percentage<60)
printf("2nd division");
else
printf("1st division");
return 0;
// Leap year //throwing an error
#include <stdio.h>
int main(){
int year;
printf("Enter year");
scanf("%d",&year);
if (year>=1900 && year<=2050)
if (year%4==0 && year!=0);
printf("It's a leap year");
else
{
printf("It's not a leap year");
return 0;
//grading using switch (Throwing an error)
#include <stdio.h>
int main(){
int marks;
printf("Enter marks: ");
scanf("%d", &marks);
switch (marks)
case 90-100 : printf("A+");
break;
case 80-90: printf("B");
break;
case 70-80: printf("C");
break;
case 60-70: printf("D");
break;
default <70 : printf("fail");
break;
return 0;
//select days using switch
#include <stdio.h>
int main(){
int day;
printf("Choose a number: ");
scanf("%d", &day);
switch(day)
case 1: printf("\nIt's Monday");
break;
case 2: printf("\nIt's Tuesday");
break;
case 3: printf("\nIt's Wednesday");
break;
case 4: printf("\nit's Thursday");
break;
case 5: printf("\nIt's Friday");
break;
case 6: printf("\nIt's Saturday");
break;
default : printf("\nIt's Sunday");
break;
return 0;
//Mark sheet with division of individual subject
#include <stdio.h>
int main () {
int sub1;
int sub2;
int total;
int percentage;
printf("enter marks of sub1: ");
scanf("%d", &sub1);
printf("Enter marks for subject2: ");
scanf("%d", &sub2);
total = sub1+sub2;
percentage=total/200;
if (percentage>=60)
printf("First division");
else if (percentage>=45)
printf("Second division");
else if (percentage>=33)
printf("Third division");
else
printf("Fail");
return 0;
// Odd even using switch //not working properly
#include <stdio.h>
int main()
int num;
printf("Enter a num: ");
scanf("%d", &num);
switch (num)
case 0 : printf("Number is even");
break;
case 1 : printf("Number is odd");
break;
default : printf("Enter a valid input");
return 0;
// Odd even using switch //Not working
#include <stdio.h>
int main()
int num;
printf("Enter a num: ");
scanf("%d", &num);
switch (num%2==0)
case 0 : printf("Number is even");
break;
case 1 : printf("Number is odd");
break;
default : printf("Enter a valid input");
return 0;
#include <stdio.h>
//Design a program that calculates the final price of a product after applying a discount. Use
the ternary operator to calculate the discount based on the original price.
int main() {
int price;
int discount;
int original_price;
printf("Enter price ");
scanf("%d", &price);
printf("Enter discount ");
scanf("%d", &discount);
original_price = price*100/100-discount;
printf("%d", original_price);
return 0;