0% found this document useful (0 votes)
1K views11 pages

1.write A Program To Print A Message in C Language

The document provides 9 C programming code examples demonstrating basic programming concepts: 1) A program to print a message 2) A program to add two numbers 3) A program to check if a number is even or odd 4) A program to swap two numbers 5) A program to subtract two numbers 6) A program to find the greatest of three numbers 7) A program to find the greatest of two numbers 8) A program to calculate the average of two numbers 9) A program to generate Fibonacci series terms

Uploaded by

Sai Printers
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views11 pages

1.write A Program To Print A Message in C Language

The document provides 9 C programming code examples demonstrating basic programming concepts: 1) A program to print a message 2) A program to add two numbers 3) A program to check if a number is even or odd 4) A program to swap two numbers 5) A program to subtract two numbers 6) A program to find the greatest of three numbers 7) A program to find the greatest of two numbers 8) A program to calculate the average of two numbers 9) A program to generate Fibonacci series terms

Uploaded by

Sai Printers
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

1.Write a program to print a message in c language.

# include<stdio.h>
# include<conio.h>
main()
{
clrscr();
printf("my name is ramesh kr. Yadav this is my first c page");
getch();
}
******output*****

my name is ramesh kr. Yadav this is my first c page

2.Program to Add two numbers.

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
a=10,b=20;
c=a+b;
printf("%d",c);
getch();
}
******output*****

3.Program to check even or odd no.


# include<stdio.h>

# include<conio.h>
main()
{
int a;
clrscr();
printf("enter any number");
scanf("%d",&a);
if(a%2==0)
printf("number is even");
else
printf("number is odd");
getch();
}
******output*******

4.Program to swap two nos.


#include<stdio.h>

#include<conio.h>
main()
{
int a,b,temp;
clrscr();
printf("enter first number");
scanf("%d",& a);
printf("enter second number");
scanf("%d",& b);
temp=a;
a=b;
b=temp;
printf("first%d,secon%d",a,&b);
getch();
}

5.Program to subtract two numbers.


#include<stdio.h>

#include<conio.h>
main()
{
int a,b,c;
clrscr();
a=30,b=20;
c=a-b;
printf("%d",c);
getch();
}
******output*****

6.Program to check Greates of three numbers.


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

main()
{
int a,b,c;
clrscr();
printf("enter first number");
scanf("%d",&a);
printf("enter second number");
scanf("%d",&b);
printf("enter third number");
scanf("%d",&c);
if(a>b)
if(a>c)
printf("a is greater");
else
printf("c is greater");
else if (b>c)
printf("b is greater");
else
printf("c is greater");
getch();
}

7.Program to check Greates of two numbers.

#include<stdio.h>
#include<conio.h>
main()
{
int a,b;
clrscr();
printf("enter first number");
scanf("%d",&a);
printf("enter second number");
scanf("%d",&b);
if(a>b)
printf("a is greater");
else
printf("b is greater");
getch();
}

8.Program to find average of two numbers.

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
float avg;
clrscr();
printf("enter two numbers");
scanf("%d%d",&a,&b);
c=a+b;
printf(sum is %d\n,c);
avg=c/2;
printf("average of two numbers %f",avg);
getch();
}

9.Program to generate fibronic series.

#include<stdio.h>
#include<conio.h>
main()
{
int a=1,b=1,c=0,limit;
clrscr();
for(limit=0;limit<=10;limit++)
{
a=b;
b=c;
c=a+b;
printf("%d\n",c);
}
getch();
}

You might also like