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

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy