C is a computer programming language. That means that you can use C to create lists of instructions for a computer to follow. C is one of thousands of programming languages currently in use.
C++ is an object oriented programming (OOP) language,
developed by Bjarne Stroustrup, and is an extension of C language. It
is therefore possible to code C++ in a "C style" or
"object-oriented style."
C was developed at Bell Laboratories in 1972 by Dennis
Ritchie. Many of its principles and ideas were taken from the earlier language
B and B's earlier ancestors BCPL and CPL.
It was named "C" because its features
were derived from an earlier language called "B", which
according to Ken Thompson was a stripped-down version of the BCPL programming
language'.
Some of the basic languages are given below:
Some of the basic languages are given below:
Form 1 sum.c
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("\n enter the value of a,b");
scanf("%d%d",&a, &b);
c=a+b;
printf("\n sum=%d",c);
getch();
}
Form 2 simple interest.c
#include<stdio.h>
#include<conio.h>
void main()
{
int p,r,t,si;
printf(" enter the value of p,r,t");
scanf(" %d%d%d",&p,&r,&t);
si=p*r*t/100;
printf("\n simple interest = %d",si);
getch();
}
Form 3 simple if.c
#include<stdio.h>
#include<conio.h>
void main()
{
float s,d=0,a;
printf("enter the save");
scanf("%f",&s);
if(s>=5000)
d=s*10/100;
a=s-d;
printf("\n a=%.f d=%.f",a,d);
}
Form 4 result.c
#include<stdio.h>
#include<conio.h>
void main()
{
int s1,s2,s3,s4,s5,total,average;
printf(" enter the value of s1,s2,s3,s4,s5");
scanf(" %d%d%d%d%d",&s1,&s2,&s3,&s4,&s5);
total= s1+s2+s3+s4+s5;
average=total/5;
printf("\n total=%d",total);
printf("\n average=%d",average);
if(average<33)
printf("\n fail");
else
printf("pass");
getch();
}
Form 5 name.c
#include<stdio.h>
#include<conio.h>
void main()
{
char n[50];
int l=0;
printf("enter your name ");
scanf("%s",n);
printf("\n My name is %s",n);
getch();
}
Form 6 gets name.c
#include<stdio.h>
#include<conio.h>
void main()
{
char n[50];
int l=0;
printf("enter your name");
gets(n);
printf("\n My name is %s",n);
getch();
}
Form 7 char 1.c
#include<stdio.h>
#include<conio.h>
void main()
{
int x=65536;
printf("x=%d",x);
}
Form 8 char 2.c
#include<stdio.h>
#include<conio.h>
void main()
{
char x = 65;
printf("x=%c",x);
}
Form 9 big number.c
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,big;
printf("\n enter the value of a,b,c");
scanf("%d%d%d",&a,&b,&c);
big=a;
if(b>big)
big=b;
if(c>big)
c=big;
printf("\n big = %d",big);
getch();
}
Form 10 basic pay.c
#include<conio.h>
void main()
{
int bp,ta,da,hra,lic,gpf,total,net;
printf(" enter the value of bp,ta,da,hra,gpf,lic");
scanf(" %d%d%d%d%d%d",&bp,&ta,&da,&hra,&lic,&gpf);
total=bp+ta+da+hra;
net=total-gpf-lic;
printf("\ntotal=%d",total);
printf("\n net salary =%d",net);
getch();
}
Form 11 constant's
#include<stdio.h>
#include<conio.h>
#define pi 3.14159
void main()
{
float a,c,r;
printf("enter the radius of a circle");
scanf("%f",&r);
a=pi*r*r;
c=2*pi*r;
printf("\n a=%.2f",a);
printf("\n c=%.2f",c);
getch();
}
Form12 gets puts.c
#include<stdio.h>
#include<conio.h>
void main()
{
char x[20];
gets(x);
puts(x);
getch();
}
Form 13 statical.c
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
static int s;
for(i=1;i<=10;i++)
{
s=s+i;
}
printf("s=%d",s);
getch();
}
Form 14 gets and putchar.c
#include<stdio.h>
#include<conio.h>
void main()
{
char x;
x=getch();
putchar(x);
getch();
}
Form 15 global.c
#include<stdio.h>
#include<conio.h>
int x;
void main()
{
int x=4;
printf("global=%d",::x);
printf("local=%d",x);
getch();
}
Form 16 compound ||
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y;
printf("enter the value of x and y");
scanf("%d%d",&x,&y);
if(x<=50 || y<=60)
printf("compound condition has passed the test");
else
printf("compound condition has fail the test");
getch();
}
Form 17 compound &&
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y;
printf("enter the value of x and y");
scanf("%d%d",&x,&y);
if(x<=50 && y<=60)
printf("compound condition has passed the test");
else
printf("compound condition has fail the test");
getch();
}
Form 18 gets.c
#include<stdio.h>
#include<conio.h>
void main()
{
char x;
printf(" enter the character");
x=getch()
printf("\n x=%c",x);
getch();
}
Form 19 convergent
#include<stdio.h>
#include<conio.h>
void main()
{
int n,b,rn=10,col=40,r;
clrscr();
printf("enter number and base");
scanf("%d%d",&n,&b);
while(n>=b)
{
r=n%b;
n=n/b;
gotoxy(col,rn);
printf("%x",r);
col=col-2;
}
gotoxy(col,rn);
printf("%x",n);
getch();
}
Form 20 power
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
double a,b,d;
printf("enter the value of a,b");
scanf("%lf%lf",&a,&b);
d=pow(a,b);
printf("d=%.2lf",d);
getch();
}
Form 21 find character
#include<stdio.h>
#include<conio.h>
void main()
{
char a [50];
int l=0;
printf("enter your name");
gets(a);
clrscr();
for(l=0;a[l]!='\0';l++);
printf("\n l=%d",l);
getch();
}
Form 22 triangel
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c;
float s,area;
printf("enter the value of a,b and c ");
scanf("%d%d%d",&a,&b,&c);
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("\n area=%.2f",area);
getch();
}
Form 23 go to
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y;
nivh:
printf("enter ther value of x,y");
scanf("%d%d",&x,&y);
if(x==5)
goto out;
goto nivh;
out:
printf("bye");
getch();
}
Form 24 array
#include<stdio.h>
#include<conio.h>
void main()
{
int arr[10],i;
clrscr();
for(i=0;i<5;i++)
{
printf("enter roll number %d",i+1);
scanf("%d",&arr[i]);
}
clrscr();
for(i=0;i<5;i++)
printf(" %d ",arr[i]);
getch();
}
Form 25 big condition.c
#include<stdio.h>
#include<conio.h>
void main()
{
int big,rn,i ,m[5];
}
clrscr();
printf("enter the marks of five subject");
for(i=0;i<5;i++)
scanf("%d",&m[i]);
big=m[0];
rn=0;
for(i=1;i<5;i++)
{
if(m[i]>big)
{
big=m[i];
rn=i;
}
}
clrscr();
printf("\n big=%d \trn=%d",big,rn);
getch();
}
Form 26 small condition.c
#include<stdio.h>
#include<conio.h>
void main()
{
int small,rn,i ,m[5];
clrscr();
printf("enter the marks of five students");
for(i=0;i<5;i++)
scanf("%d",&m[i]);
small=m[0];
rn=0;
for(i=1;i<5;i++)
if(m[i]<small)
{
{
small=m[i];
rn=i;
}
}
clrscr();
printf("\n small=%d \t rn=%d",small,rn);
getch();
}
Form 27 total and average
#include<stdio.h>
#include<conio.h>
void main()
{
int tot=0,i ,m[5];
float av;
clrscr();
printf("enter the marks of five students");
for(i=0;i<5;i++)
scanf("%d",&m[i]);
for(i=0;i<5;i++)
{
tot=tot+m[i];
}
av=tot/5.0;
clrscr();
printf("tot=%d \t av=%.2f",tot,av);
getch();
}
Form 28 power
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
double a,b,d;
printf("enter the value of a,b");
scanf("%lf%lf",&a,&b);
d=pow(a,b);
printf("d=%.2lf",d);
getch();
}
Form 29 area
#include<stdio.h>
#include<conio.h>
void main()
{
float s,d=0,a;
printf("enter the sale");
scanf("%f",s);
if(s=5000)
d=s*10/100;
a=s-d;
printf("\na=%.f d=%.f",a,d);
getch();
}
Form 30 display
#include<stdio.h>
#include<conio.h>
void display()
{
printf(" i am nidhi\n");
}
void main()
{
int i;
clrscr();
for(i=1;i<=10;i++)
{
printf("%d",i);
display();
}
getch();
}
Form 31 double dimaintion
#include<stdio.h>
#include<conio.h>
void main()
{
int stu[3][4],r,c;
clrscr();
for(r=0;r<3;r++)
{
for(c=0;c<4;c++)
{
printf("enter marks of students row number %d coulmn number %d ",r+1,c+1);
scanf("%d",&stu[r][c]);
}
}
clrscr();
for(r=0;r<3;r++)
{
for(c=0;c<4;c++)
{
printf(" %d ",stu[r][c]);
}
printf("\n");
}
getch();
}
Form 32 factorial.c
#include<stdio.h>
#include<conio.h>
long int fact(int x)
{
long int res=1;
while(x>0)
{
res=res*x;
x--;
}
return (res);
}
void main()
{
int n;
clrscr();
printf(" enter the value of n");
scanf("%d",&n);
printf("\n factorial=%ld",fact(n));
getch();
}
Form 34 addition of even numbers
#include<stdio.h>
#include<stdio.h>
#include<conio.h>
void main()
{
int i,m,sum=0,n=2;
printf("enter the value of m");
scanf("%d",&m);
for(i=1;i<=m;i++)
{
sum=sum+n;
n=n+2;
}
printf("\n sum=%d",sum);
getch();
}
Form 35 pi
#include<stdio.h>
#include<conio.h>
#define pi 3.14159
void main()
{
float a,c,r;
printf("enter the radius of a circul");
scanf("%f",&r);
a=pi*r*r;
c=2*pi*r;
printf("\n a=%.2f",a);
printf("\n c=%.2f",c);
getch();
}
Form 36 table.c
#include<stdio.h>
#include<conio.h>
void table()
{
int i,p,n;
clrscr();
printf("enter the value of n");
scanf("%d",&n);
for(i=1;i<=10;i++)
{
p=i*n;
printf("\n %d * %d = %d ",i,n,p);
}
getch();
}
void main()
{
table();
}
Form 37 vowels.c
#include<stdio.h>
#include<conio.h>
void main()
{
char w[50];
int a=0,e=0,i=0,o=0,u=0,c=0;
puts("enter the word ");
gets(w);
while(w[c]!='\0')
{
if(w[c]=='a')
a++;
else
if(w[c]=='e')
e++;
else
if(w[c]=='i')
i++;
else
if(w[c]=='o')
o++;
else
if(w[c]=='u')
u++;
c++;
}
if(a>0)
printf("a");
else
if(e>0)
printf("e");
else
if(i>0)
printf("i");
else
if(o>0)
printf("o");
else
if(u>0)
printf("u");
if(a==0&&e==0&&i==0&&o==0&&u==0)
printf("no vowels present ");
getch();
}
Form 38 point swap.c
#include<stdio.h>
#include<conio.h>
void swap(int *a,int *b)
{
int t;
t=*a; *a=*b; *b=t;
printf("\n a=%d \t b=%d",*a,*b);
}
void main()
{
int x=5,y=10;
swap (&x,&y);
printf("\n x=%d \t y=%d",x,y);
getch();
}
Form 39 copy char.c
#include<stdio.h>
#include<conio.h>
void copy(char *a,char *b)
{
while(*a!='\0')
{
*b++=*a++;
}
*b='\0';
}
void main()
{
char x[20], y[20];
printf("enter a word");
gets(x);
copy(x,y);
printf("\n x=%s \t y=%s",x,y);
getch();
}
Form 40 struct.c
#include<stdio.h>
#include<conio.h>
struct student
{
char n[20];
int age;
};
void main()
{
struct student s;
printf(" enter name ");
gets(s.n);
printf(" enter age ");
scanf("%d",&s.age);
clrscr();
printf("\n name is %s \t age is %d",s.n,s.age);
getch();
}
Form 41 student.cpp
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class student
{
private:
char n[20];
int age,m1,m2,m3;
float per;
public:
void input()
{
cout<<"enter the name ";
cin>>n;
cout<<"enter the age";
cin>>age;
cout<<"enter the marks of three subject";
cin>>m1>>m2>>m3;
}
void cal()
{
per=(m1+m2+m3)/3.0;
}
void display()
{
cout<<"name is "<<n<<" age is "<<age<<" per="<<per;
}
};
void main()
{
student o;
o.input();
o.cal();
o.display();
getch();
}
Form 42 student class.cpp
#include<iostream.h>
#include <conio.h>
class student
{
private:
char n[20];
int age,m1,m2,m3;
float per;
public:
input()
{
cout<<"enter the name ";
cin>>n;
cout<<"enter the age";
cin>>age;
cout<<"enter the marks of three subject";
cin>>m1>>m2>>m3;
}
cal()
{
per=(m1+m2+m3)/3.0;
}
display()
{
cout<<"name is "<<n<<" age is "<<age<<" per="<<per;
}
};
void main()
{
student o;
o.input();
o.cal();
o.display();
getch();
}
Form 43 palimor.cpp
#include<iostream.h>
class areas
{
private:
float ar;
public:
void area(float rad)
{
ar=3.14*rad*rad;
}
void area(float l,float b)
{
ar=l*b;
}
void display()
{
cout<<"area="<<ar<<endl;
}
};
void main()
{
areas o1,o2;
o1.area(5.5);
o2.area(7.5,8.5);
o1.display();
o2.display();
}
Form 44 palimor1.cpp
#include<iostream.h>
class abc
{
public:
void display()
{
cout<<"without arguement"<<endl;
}
void display(int x)
{
cout<<"with one argument x="<<x<<endl;
}
void display( int x,int y)
{
cout<<"with two argument x="<<x<<"y="<<y<<endl;
}
};
void main()
{
abc o,o1,o2;
o.display();
o1.display(100);
o2.display(500,1000);
}
Form 45 big number.cpp
#include<iostream.h>
#include<conio.h>
class bigg
{
private:
int x,y,z,big;
public:
void input()
{
cout << "enter the value of x,y,z";
cin>> x>>y>>z;
}
void cal()
{
big=x;
if(y>big)
big=y;
if(z>big)
big=z;
}
void display()
{
cout <<"\n big="<<big;
}
};
void main()
{
bigg o;
o.input();
o.cal();
o.display();
getch();
}
No comments:
Post a Comment