Tuesday, 22 February 2022

check whether the entered character is a lowercase or not in C

 #include <stdio.h>


int main(){

char ch;
printf("Enter the character\n");
scanf("%c",&ch);
if (ch>=97 && ch<=122)
{
    printf("The entered character is a lowercase\n");

}
else
printf("The entered character is not a lowercase\n");
 return 0;
}

convert from km to m and cm

 #include<stdio.h>

int main()
{
int A;
printf("Enter the distance in kilometers:\n");
scanf("%d",&A);
printf("The distance in meters is:%d mtr\n",A*1000);
printf("The distance in centimeters is:%d cms",A*100000);
}

Friday, 18 February 2022

calculate income tax in C

 #include <stdio.h>


int main()
{
    float income, tax = 0;
    printf("Enter your income\n");
    scanf("%f", &income);
    if (income >= 250000 && income <= 500000)
    {
        tax = tax + 0.05 * (income - 250000);
    }

    if (income >= 500000 && income <= 1000000)
    {
        tax = tax + 0.2 * (income - 500000);
    }

    if (income >= 1000000 )
    {
        tax = tax + 0.3 * (income - 500000);
    }
    printf("Total tax you have to pay is:%f", tax);
    return 0;
}

Wednesday, 16 February 2022

SwitchCase in C

 #include <stdio.h>


int main(){
int rating;
printf("Enter your rating:");
scanf("%d",&rating);
switch(rating)
{
    case 1:printf("Your rating is 1\n");
    break;
    case 2:printf("Your rating is 2\n");
    break;
    case 3:printf("Your rating is 3\n");
    break;
    case 4:printf("Your rating is 4\n");
    break;
    case 5:printf("Your rating is 5\n");
    break;
    default:printf("Your rating is invalid\n");
    break;
}


 return 0;
}

Even Odd number in C

 #include <stdio.h>


int main(){
int a;
printf("Enter a number:");
scanf("%d",&a);
if(a%2==0)
{
    printf("%d is an even number",a);
}
else{
    printf("%d is an odd number",a);
}

 return 0;
}

Expression in c

 #include <stdio.h>


int main(){
int x=2,y=3,z=3,k=1;
int result;
result=3*x/y-z+k;
printf("The value of result is:%d",result);
 return 0;
}

Divisibility Test in C

 #include <stdio.h>


int main()
{

int num;
printf("Enter a number:");
scanf("%d",&num);
printf("Divisibility test returns:%d", num%97);
 return 0;
}

Table of a number in C

 #include <stdio.h>


int main()

{
    int a;
    printf("Which table do you want to see:");
    scanf("%d",&a);
    printf("The table of %d:\n",a);
    for(int i=1;i<=10;i++)
    {
       
        printf("%d",a);
        printf("x""%d:",i);
        printf("%d\n",a*i);
    }

 return 0;
}

calculating simpleInterest in C

 #include <stdio.h>


int main()

{
    int principal=100, rate=4, years=1;
    int SimpleInteret= (principal*rate*years)/100;
    printf("The Simple interest is:%d",SimpleInteret);

 return 0;
}

Coverting temperature from celsius to Fehrenheit in C

 #include <stdio.h>


int main()

{
    float c=34;
    float t;
    t=(c * 9/5) + 32;
    printf("The temperatue in Fahrenheit is:%f",t);
 return 0;
}

Volume of a cyliner in C

 #include <stdio.h>


int main()

{
    int radius=34;
    float pi=3.14;
    int height=9;
    printf("The volume of a cylinder is: %f",pi*radius*radius*height);
 return 0;
}

Area of a circle in C

 #include <stdio.h>


int main()

{
    int radius=34;
    float pi=3.14;
    printf("The area of a circle is: %f",pi*radius*radius);
 return 0;
}

Find out area of a rectangle by taking input from user in C

 #include <stdio.h>


int main(){
int l,b,area;
printf("Enter length:");
scanf("%d",&l);
printf("Enter breadth:");
scanf("%d",&b);
printf("The area of a rectangle is:%d",l*b);


 return 0;

Tuesday, 15 February 2022

Take input from used and then add 2 sums in C

 #include <stdio.h>

int main()
{
    int a,b,c;
    printf("Enter the value of a:");
    scanf("%d", &a);
    printf("Enter the value of b:");
    scanf("%d", &b);
    printf("The sum of a and b is:%d",a+b);

    return(0);
}

Fibonacci Sequence in C language

 #include <stdio.h>

int main()
{
    int i;
    int a[20];

    a[0] = 1;
    a[1] = 1;
    printf("The following is the Fibonacci Sequence");
    for (i = 0; i < 12; i++)
    {
        a[i + 2] = a[i] + a[i + 1];

        printf("%d\n", a[i]);
    }
    return (0);
}