Showing posts with label C-programming. Show all posts
Showing posts with label C-programming. Show all posts

Wednesday, September 29, 2021

WAP a program to find the sum of any two decimal number using C programming. (sum-of-two-decimal-number-simple -interest-equilateral-SI-greater-among-two-numbers)

1.WAP a program to find the sum of any two decimal number using C programming.

#include <studio.h>

#include <conio.h)

main ()

{

float a, b, sum;

printf ("Enter the first decimal number;);

printf ("Enter the second decimal number")

scanf (''%f" &a);

printf (''enter the second decimal number'')

scanf ("%f" &a);

sum = a + b

printf ("sum of two number is %f", sum);

getch();

}

2.Write a program in C to find simple interest.

#include <studio.h>

 int main( ) 

{

float principle, time, rate, SI;

printf ("Enter principle")

scanf (''%f", & principle);

printf ("enter a time;");

scanf ("%f", & rate);

SI=( principle * time * rate)/100

printf ("simple interest = %f"; SI);

return 0

3.wap to find out the greatest number among 3 entered numbers.

#include <studio.h>

int main < >

{

double n1, n2, h3;

 printf ("Enter three different numbers ;"); 

scanf ("% If  %If %if''; & n1, &n2, &n3);

// if n1 is greater than n2 and n3, n1 is the largest

if  (n1) = n2 && n1>=n3)

 printf ("%, 2f is the greater number''; n1 

// if n2 is the greater than both n1 and n3, n2 is the largest 

elseif (n2>= n1 && n 2 >=n3)

printf (''%, 2 is the greater number"; n2);

// if the both above conditions are false, n3 is the grater 

else 

printf ("% 2 is the largest number";n3);

return 0

4. wap to find out if a number is even or odd using the if-else statement in C programming.

#include <studio.h>

int main ()

int num 1

printf (" enter a number");

 scanf ("%d", & num1)

if (num1%2 == 0) // test-condition

{

printf ("num1 is even number");

}

else

printf(" num 1 is odd number");

return 0;

5.WAP to enter the sides of a triangle and find out if its equilateral or not.

#include <studio.h>

int main()

{

int a, b, c

printf ("Enter three sides of triangle");

 scanf ("%d %d %d", &  a, b, c);

if (a= = b && b== c)

 printf  ("Equilateral triangle");

}

else

{

printf ("scalene triangle");

}

return 0;

}

Click here for more...

Sunday, September 26, 2021

What is C Programming Language? C (Programming Language)- structure, introduction, basics, history, meaning.

 What is C Programming Language? C (Programming Language)-structure, introduction, basics,       history, meaning.

Structured Programming in C

A computer requires commands or instructions to perform tasks. A set of instructions is called a program. A program is created to solve a particular task. The group of programs is called software. There are different types of programming language such as high-level language (HLL), assembly language, and low-level language (LLL) to write programs. There are several approaches to programming which include structured, unstructured, procedural, modular, object-oriented programming, etc.

Structured programming

Structured programming is a subset of procedural programming. It enforces a logical structure on the program to make it more efficient and easier to understand and modify. It is considered as a precursor to Object-Oriented Programming (OOP) and follows a top-down design approach, where a system is divided into compositional subsystems. It is a programming paradigm that facilitates the creation of programs with readable code and reusable components. It helps to improve the clarity, quality, and development time of a computer program by making extensive use of control flow statements of selection (if- then- else/switch)) and repetition (while and for), block structures, and subroutines. C, C+, C++, C#, Java, PERL, Ruby, PHP, ALGOL, and Pascal are examples of Structured Programming language.

Advantages of structured programming

  • Structured programming is user-friendly and easy to understand.
  •  It is easy to debug the program.
  • It reduces the complexity of the program as the program can be divided into several units.
  •  It is a machine-independent programming language. It increases the productivity of application program development.
  • It follows the modularity concept which allows multiple programmers to work on a single software.


C language

C is the structured high-level programming language. It was developed by Dennis M. Ritchie at Bell Laboratories in 1970. It is used to develop system software. It is one of the most popular computer languages. It was developed to write the UNIX Operating System. It is also considered the middle-level programming language. C is the result of a development process that started with an older language called BCPL BCPL was developed by Martin Richards, and it influenced a language called B.

Features of C language


The different features of the C language are:

  1. It is a structure-oriented programming language and it aims at the clarity of the program, reduces or breaks down a program into several small modules.
  2. The program execution in C is faster and efficient than other programming languages which are interpreter-based.
  3. It is considered as because it supports the feature of both high-level language and assembly language and also manipulates memory address.
  4. It allows the programmer to create their own function and add it to the C library to use in other programs. It supports varieties of data types and has a rich and powerful set of operators.
  5. It is a case-sensitive programming language that understands the capital alphabets and small alphabets as different values. For example, "Programming" and "PROGRAMMING" are different values for C Language.

Limitation of C Language


C has some limitations though it is a powerful programming language. The limitations of C language are:

  1. It has no run-time type checking.
  2. It doesn't have the feature of reusability of source code extensively It does not support Object-Oriented Programming (OOP).
  3.  It provides no data protection.
  4. It has only 32 keywords.
  5. Compilers can only identify errors and are incapable of handling exceptions (run-time errors). C language.

Applications of C language

  1. It is used for scripting system applications in Windows, UNIX, and Linux Operating System.
  2. It is used in the development of other languages such as C++, C#, Java, JavaScript, Perl, UNIX's C Shell, PHP, and Python.
  3. It is used to develop firmware for various electronics devices.
  4. It is used for creating Compilers of different languages.
  5. It is widely used in IoT applications.

What is C programming & who invented it?

C is developed by Dennis, Ritchie. C is a structured programming language. C supports functions that enabled easy maintainability of code, by breaking large files Into smaller modules. Comments in Ċ provide easy readability. C is a powerful language. 

Program Structure

A sample program

#include <studio.h>

int main()

....other statements

// comments after double slash

}

1. what are header files a explain.

 "Header files

The files that are specified in the include section are called header files. There is a precompiled file that the header function defined in them. We can sell these functions in our program by supplying parameters. Header files are given an extension. h. The c source file is given an extension. c 

2. what is the main () in & programming & why it is an important Main function?

This is the entry point of a program. when a file is executed, the start point is the main function. From the main function, the flow goes as per the programmer's choice. Programmers' choice & There are may or may not be other functions written by the user in a program. The main function is compulsory for any program.

writing the first program

 # include <studio .h>
int main() 

print f ("Hello"); 

return 0;

}

• The program print! Hello on the screen when We execute it.



4. Explain different data types in C?

    Data types in C 

    → Primitive data types.

        - int, float, double, char 

    → Aggregate data type

        - Arrays come under this category Array, which can contain a collection of int or float char or double data.

      User-defined data types.

        - structures and enum fall under this category: s what are the rules for naming variables in e: 

5. Variable names - Rules

→ Should not be a reserved word like int etc.

→ Should start with a letter or an underscore 6). can contain letters, numbers, or underscore... 

→No other special characters are allowed including space...

→Variable names are sensitive. -A and a are different. 

6. What are the operators used in the c language. Explain.


Operators :

•Arithmetic (+,-. *, 1, %.)

• Relational (4, >, <=, >=, = =,!=)

• Logical (&d, 11, 1) 

• • Alignment (=)

• Compound assignment (+=, *=, -=, !=, %=, &=, !=)

• Shift (right shift>>, left shift <<) Bitwise ( &,!)

• Alignment (=)

• Compound assignment (+=, *=, -=, !=, %=, &=, !=)

• Shift (right shift>>, left shift <<)

Click here for more...




Sharkey

Simple way to make website using HTML only.

 A simple way to make a website using HTML only. <!DOCTYPE html> <head>         <title>Document</title> </head...