Skip to main content

programming in c







1/ write a c program “Hellow Ward”
#include<stdio.h>
int main()
{
printf("Hello World ");
return 0;
}
2/ Write a program using one print statement to print the pattern of asterisks as shown below:
*
*  *
*  *  *
*  *  *  *

#include<stdio.h>
int main()
{
    printf("n**\n***\n***\n****");
    return 0;

}


#include<stdio.h>
int main()
{
    float a,b,sum;
    printf("The frist Number=");
    scanf("%f",&a);
    printf("The second  Number=");
    scanf("%f",&b);
    sum=a+b;
printf("the add integersNumber:%f",sum);
return 0;
}


#include<stdio.h>
int main()
{
            float a,b,mul;
            printf("Enter the 1st Float Number:");
            scanf("%f",&a);
            printf("Enter the 2nd float Number:");
            scanf("%f",&b);
            mul=a*b;
            printf("Multiplicaiton  of two Number :%f",mul);
            return 0;
}

5/  C Program to Compute Quotient and Remainder

#include<stdio.h>
int main()
{
            int num,rem,quo,div;
            printf("Enter any Number:");
            scanf("%d",&num);
            printf("\nEnter the divisor:");
            scanf("%d",&div);
            rem=num%div;
            quo=num/div;
            printf("The Quotient of Number is :");
            printf("%d",quo);
            printf("The Remainder of Number is :");
            printf("%d",rem);
            return 0;
}
6/C Program to Swap Two Numbers
#include<stdio.h>
int main()
{
            int a,b,temp;
            printf("Enter the first Number:");
            scanf("%d",&a);
            printf("\nEnter the second Number:");
            scanf("%d",&b);
            printf("\nNumber Before swaping:");
            printf("\n%d\t%d",a,b);
            temp=a;
            c=b;
            b=temp;
            printf("\nNumber After swaping:");
            printf("\n%d\t%d",a,b);
}


#include<stdio.h>
#include<math.h>
int main()
{
            int num1;
            printf("Enter a Number:");
            scanf("%d",&num1);
            if(num%2==0)
            printf("\n Entered Number is Even.");
            else
            printf("\n Entered Number is Odd.");
            return 0;
}
8/C Program to Check Whether a Character is Vowel or Consonant.
#include <stdio.h>
int main()
{
    int num1, num2, num3;
    printf("Enter the values of num1, num2 and num3\n");
    scanf("%d %d %d", &num1, &num2, &num3);

    printf("num1 = %d\tnum2 = %d\tnum3 = %d\n", num1, num2, num3);

    if (num1 > num2)
    {
        if (num1 > num3)
        {
            printf("num1 is the Largest t among three \n");
        }
        else
        {
            printf("num3 is the Largest  among three \n");
        }
    }
    else if (num2 > num3)
        printf("num2 is the Largest  among three \n");
    else
        printf("num3 is the Largest  among three \n");
        return 0;
}



10/ write a C Program to Check Leap Year

#include<stdio.h>
int main()
{
            int year;
            printf("Enter a year:");
            scanf("%d",&year);
            if(year%4==0)
            printf("\nThe Entered year is Leap year.");
            else
            printf("\nThe Entered year is not a Leap year.");
            return 0;
}




11/ Relationship between Celsius and Fahrenheit is governed by the formula
       F=9C/5 +32
(a) Celsius to Fahrenheit.

#include<stdio.h>
int main()
{
    float c,f;
            printf("Inter the value of Calciaus:");
            scanf("%f",&c);
            f=((celsius * 9)/5) + 32;
            printf(" the value of Farenheight:%.2f",f);
            return 0;
}

 (b)Fahrenheit to Celsius.
#include <stdio.h>
int main()
{
    float celsius, fahrenheit;
    printf("Enter temperature in Fahrenheit: ");
    scanf("%f", &fahrenheit);
    celsius = (fahrenheit - 32) * 5 / 9;
    printf(" the value of celsius= %.2f ", celsius);

    return 0;
}






12.write a c program to Area of a triangle is given by the formulae
A=√S(S-a)(S-b)(S-c)    where a,b,c are the sides of the triangle.
#include <stdio.h>
            #include <math.h>
            int main()
            {
                int s, a, b, c, area;
                printf("Enter the values of a, b and c \n");
    scanf("%d %d %d", &a, &b, &c);
                s = (a + b + c) / 2;  /* compute s */
   area = sqrt(s * (s - a) * (s - b) * (s - c));
                printf("Area of a triangle = %d \n", area);
                return 0;
            }





The end


writen by Boniyeamin laju

Comments

Popular posts from this blog

Discrete Mathematics - Rules of Inference

To deduce new statements from the statements whose truth that we already know,  Rules of Inference  are used. What are Rules of Inference for? Mathematical logic is often used for logical proofs. Proofs are valid arguments that determine the truth values of mathematical statements. An argument is a sequence of statements. The last statement is the conclusion and all its preceding statements are called premises (or hypothesis). The symbol “ ∴ ∴ ”, (read therefore) is placed before the conclusion. A valid argument is one where the conclusion follows from the truth values of the premises. Rules of Inference provide the templates or guidelines for constructing valid arguments from the statements that we already have. Table of Rules of Inference Rule of Inference Name Rule of Inference Name P ∴ P ∨ Q P ∴ P ∨ Q Addition P ∨ Q ¬ P ∴ Q P ∨ Q ¬ P ∴ Q Disjunctive Syllogism P Q ∴ P ∧ Q P Q ∴ P ∧ Q Conjunction P → Q Q → R ∴ P → R P → Q Q → R ∴ P → R ...

Digital Circuits - Shift Registers

We know that one flip-flop can store one-bit of information. In order to store multiple bits of information, we require multiple flip-flops. The group of flip-flops, which are used to hold (store) the binary data is known as  register . If the register is capable of shifting bits either towards right hand side or towards left hand side is known as  shift register . An ‘N’ bit shift register contains ‘N’ flip-flops. Following are the four types of shift registers based on applying inputs and accessing of outputs. Serial In − Serial Out shift register Serial In − Parallel Out shift register Parallel In − Serial Out shift register Parallel In − Parallel Out shift register Serial In − Serial Out (SISO) Shift Register The shift register, which allows serial input and produces serial output is known as Serial In – Serial Out  (SISO)  shift register. The  block diagram  of 3-bit SISO shift register is shown in the following figure. This block d...

discrete mathematics: Venn Diagrams

Venn Diagrams Venn diagram, invented in 1880 by John Venn, is a schematic diagram that shows all possible logical relations between different mathematical sets. Examples Set Operations Set Operations include Set Union, Set Intersection, Set Difference, Complement of Set, and Cartesian Product. Set Union The union of sets A and B (denoted by  A ∪ B A ∪ B ) is the set of elements which are in A, in B, or in both A and B. Hence,  A ∪ B = { x | x ∈ A   O R   x ∈ B } A ∪ B = { x | x ∈ A   O R   x ∈ B } . Example  − If  A = { 10 , 11 , 12 , 13 } A = { 10 , 11 , 12 , 13 }  and B =  { 13 , 14 , 15 } { 13 , 14 , 15 } , then  A ∪ B = { 10 , 11 , 12 , 13 , 14 , 15 } A ∪ B = { 10 , 11 , 12 , 13 , 14 , 15 } . (The common element occurs only once) Set Intersection The intersection of sets A and B (denoted by  A ∩ B A ∩ B ) is the set of elements which are in both A and B. Hence,  A ∩ B = { x | x ∈ A   A N D...