Basic C Programmes

Addition of two numbers

#include <stdio.h>

#include <conio.h>

void main()

{

               clrscr;

               int a,b,c;

               printf(“entr the value of a “);

               scanf(“%d”,&a);

               printf(“enter the value of b “);

               scanf(“%d”,&b);

               c=a+b;

               printf(“the sum is %d”,c);

               getch();

}

output

———-

Enter the value of a 5

Enter the values of b 2

The sum is 14

While loop

#include <stdio.h>

void main()

{

               int n=1;

               while(n<10)

               {

                   printf(“%d”,n);

                   n++;

               }

}

output


123456789

Leave a comment

Create a website or blog at WordPress.com

Up ↑

Design a site like this with WordPress.com
Get started