Program: Addition of two given numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
a=10;
b=15;
c=a+b;
printf("\n
Addition=%d", c);
getch();
}
Output:
Addition=25
Program: Addition of two given number.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf(" Enter two
numbers");
scanf("%d%d",&a,&b);
c=a+b;
printf("\n
Addition=%d", c);
getch();
}
Output:
Enter two numbers 20
30
Addition=50
#include<stdio.h>
#include<conio.h>
void main()
{
int roll_no,fee,age;
clrscr();
printf("Enter roll_no,fee
and age");
scanf("%d%d%d",&roll_no,&fee,&age);
printf("\n Roll
No.=%d",roll_no);
printf("\n Fee=%d",
expense);
printf("\n Age=%d",
age);
getch();
}
Output:
Enter roll_no,fee and age 1
500
15
Move No.=1
Fee=500
Age=15
Program: Change Celsius to Fahrenheit.
#include<stdio.h>
#include<conio.h>
void main()
{
float c,f;
clrscr();
printf("\n Enter
temperature in Celsius ");
scanf("%f",
&c);
f=32+(c*9)/5;
printf("\n Temperature in
Fahrenheit=%f",f);
getch();
}
Output:
Enter temperature in Celsius 20
Temperature in Fahrenheit=68
Program: C Program to check greater than and less than number:
#include<stdio.h>
#include<conio.h>
void main()
{
int no;
clrscr();
printf("\n Enter
no.");
scanf("%d",&no);
if(no<100)
{
printf(" No. is less than
100");
}
else
{
printf((" No. is greater
than 100");
}
getch();
}
Output:
Enter no. 50
No. is less than 100
Program: Enter name and salary, salary increase by 10% and print the same.
#include<stdio.h>
#include<conio.h>
void main()
{
int salary;
char name[10];
clrscr();
printf("\n Enter name and
salary");
scanf("%s%d",
&name, &salary);
salary=salary+(salary*10)/100;
printf("\n Name=%s",
name);
printf("\n
Salary=%d", Salary);
getch();
}
Output:
Enter name and salary Mona
10,000
Name=Mona
Salary=11000
Program: Enter name and salary, if salary less than 1000 then increase by 200 else increase by 100.
#include<stdio.h>
#include<conio.h>
void main()
{
int salary;
char name[10];
clrscr();
printf("\n Enter name and
salary");
scanf("%s%d",
&name, &salary);
if(salary<=1000)
{
salary=salary+100;
}
else
{
salary=salary+200;
printf("\n Name=%s",
name);
printf("\n
Salary=%d", salary);
}
getch();
}
Output:
Enter name and salary Mona
1200
Name=Mona
Salary=1400
Program: Find even and odd number.
#include<stdio.h>
#include<conio.h>
void main()
{
int no;
clrscr();
printf("\n Enter
no");
scanf("%d", &no);
if(no%2==0)
{
printf(" No is
even");
}
else
{
printf(" No is odd");
}
getch();
}
Output:
Enter no 4
No is even
Program: Check which number is greater.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("\n Enter any two
number");
scanf("%d%d",&a,&b);
if(a>b)
print("a is
greater");
else
print("b is
greater");
getch();
}
Output:
Enter any two number 5
8
b is greater.
Some other links:
No comments:
Post a Comment