Tuesday, 12 February 2019

Beginners basic c program

Basic C Program For Beginners

Hello!Friend I tells us some basic program for beginners in c programming language.C language has developed by dennis ritchie in 1972.It has developed in AT & BELL LAB in USA.It is a middle level language.

Some basic program


Addition of two number.

#include<studio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
print("enter the value of a\n");
scanf ("%d",&a);
Printf("enter the value of b\n");
scanf ("%d",&b);
c=a+b;
printf("sum of :%d",c);
getch();
}
Output:

enter the value of a 10

enter the value of b30

Sum of :40

Write a program substraction of two number.
https://onlinesantoffers.blogspot.com/?m=1


Write a program swapping of two number
with third party

#include<studio.h>
#nclude<conio.h>
void main()
{
int a,b,t;
clrscr();
printf("enter the value of a and b");
scanf("%d%d",&a,&b);
t=a;
a=b;
b=t;
printf("swapping value of a and b %d%d",a,b);
getch ();
}
Output:
enter the value a and b 10
20
Swapping  value a and b 10
20



Write a program swapping of two variable without third party.

#include<stdio.h>
#include<condo.h>
void main()
{
int a,b;
printf ("enter the value of a and b");
scanf ("%d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf("swapping value a and b:%d%d",a,b);
getch ();
}

Output:
enter value a and b 10
20
Swapping value a and b:20
10

Write a program to find a square root of a particular number.


#include<stdio.h>
#include<conio.h>
void main ()
{
Float n,p;
printf("enter value of n \n");
scanf ("%f",&n);
p=sqrt (n);
printf(" value of p:%f",p);
getch ();
}

Output:
enter value of n 4
Value of p:2

No comments:

Post a Comment

If, if else and nested if program in c language 2019

If ,if else and nested if program in c language If statement in c  language Syntax: Example: If else statement in c ...