#include<stdio.h>
#include<conio.h>
int mul(int);
int main()
{
int a=10;
printf("%d", mul(a));
getch();
}
int mul(int a)
{
int x;
for(x=1;x<=a;x++)
{
printf("%d\n",x);
}
}
#include <stdio.h>
#include <conio.h>
int main()
{
float radius, area; // declare vaviables
printf("Enter radius of circle: ");
scanf("%f", &radius);
area = 3.1415 * radius * radius; // Formula to find area of circle
printf("%f\n", area);
getch();
}
#include <iostream>
#include <string>
using namespace::std;
class employee
{
string first_name;
string last_name;
int salary;
public:
employee()
{
first_name='NULL';
last_name='NULL';
salary=0;
}
void setFirstName()
{
cout<<"Enter Your First Name: ";
cin>>first_name;
}
void setlastName()
{
cout<<"Enter Your Last Name: ";
cin>>last_name;
}
void setSalary()
{
cout<<"Enter Your Salary: ";
cin>>salary;
if(salary<0)
{
salary=0;
}
}
void dsplayFirstName()
{
cout<<"Your First Name is: "<<first_name<<endl;
}
void displayLastName()
{
cout<<"Your Last Name is: "<<last_name<<endl;
}
void displaySalary()
{
cout<<"Your Salary is: "<<salary<<endl;
}
};
int main()
{
employee a1;
a1.setFirstName();
a1.setlastName();
a1.setSalary();
a1.dsplayFirstName();
a1.displayLastName();
a1.displaySalary();
system("pause");
}
#include <iostream>
using namespace::std;
class date
{
int day;
int month;
int year;
public:
int setdate(int, int, int);
void display()
{
cout<<day<<"/"<<month<<"/"<<year<<endl;
}
};
int date::setdate(int d, int m, int y)
{
day=d;
month=m;
year=y;
}
int main()
{
int d, m, y;
date a1;
cout<<"Enter Day: "; cin>>d;
cout<<"Enter Month: "; cin>>m;
cout<<"Enter Year: "; cin>>y;
a1.setdate(d, m, y);
a1.display();
system("pause");
}
#include <stdio.h>
#include <conio.h>
main()
{
int a, b;
printf("Enter To Numbers: ");
scanf("%d%d", &a, &b);
//swaping
a=a+b;
b=a-b;
a=a-b;
printf("%d %d", a, b);
getch();
}
#include<stdio.h>
#include<conio.h>
int main()
{
char ch;
printf("Enter a chararcter: ");
ch=getche();
printf("\nThe ASCII Code for \%c is %d",ch,ch);
getch();
}
#include<stdio.h>
#include<conio.h>
int main()
{
float r,v,area;
printf("Enter the radius of the sphere\n ");
scanf("%f", &r);
area=4*3.14*r*r*r;
v=(4/3.14)*3.14*r*r*r;
printf("volume of the sphere=%f\n", v);
printf("area of sphere=%f\n", area);
getch();
}