Wednesday, 3 July 2019

C basic programing by Amarjeet kumar singh

How to Print Hello world programe in C



#include<stdio.h>
#include<conio.h>

void main()     /*code will start execution from main */
{
clrscr();     
printf("Hello world");
getch();
}


How to add two numbers in C to taking input from the users


#include<stdio.h>
#include<conio.h>

void main()
{
int a,b,sum;  
clrscr();
printf("enter first number:");
scanf("%d",&a);
printf("enter second number:");
scanf("%d",&b);
sum=a+b;
printf("your sum is=%d",sum);
getch();
}

How to print table in c using for Loop


#include<stdio.h>
#include<conio.h>

void main()
{
inta,b;
clrscr();
printf("enter the number :");
scanf("%d",&a);
for(b=1;b<=10;b++)
{
printf(%d*%d=%d\n",a,b,a*b);
}
getch();
}



C program to swap two numbers 

#include<stdio.h>
#include<conio.h>
void main()
{
    int a,b,temp;
    printf("enter the two numbers:");
    scanf("%d%d",&a,&b);
    temp=a;
    a=b;
    b=temp;
    printf("a=%d b=%d",a,b);
    getch();
}


How to print area of circle and circumference in C

#include<stdio.h>
#include<conio.h>

void main()
 {

   int rad;
   float PI = 3.14, area, ci;

   printf("\nEnter radius of circle: ");
   scanf("%d", &rad);

   area = PI * rad * rad;
   printf("\nArea of circle : %f ", area);

   ci = 2 * PI * rad;
   printf("\nCircumference : %f ", ci);

   getch();
}



To learn more programing and practice in C language follow this blog thanks have a nice day to all of you.






No comments:

Post a Comment

Featured post

 Top 10 Array Coding Question For Interview: (1)Write a program to find smaller element in Array Solution:      public class SmallerElementI...