Pages

Saturday, 21 April 2012

c langugages program and notes


CC LANGUAGE

INTRODUCTION: -
C LANGUAGE DEVELOPS IN AT&T LABORATERY IN AMERICA BY “DENIS
RITCHIE”, YEAR 1972.

         
C CHARACTAR SET:-
                                                CHARACTER’S - A-Z, a-z.
                                                NUMERIC- BETWEEN 0 TO 9 ALL NUMBER’S
                                                SPECIAL SIGN- ~,” @, #, $, %, ^, &, *, (), _, -, +, =,
                                                                   {}, [ ], :, ‘, “”, ?, /.


C CONSTANT:-
1)    PRIMARY CONSTANT                   2) SECONDARY CONSTANT
ØINTEGER                                           ARRAY
ØREAL                                                   POINTOR
ØCHARACTAR                                     STRUCTURE
Ø-                                                             UNION
Ø-                                                             ENUM ETC.


NOTE:-
üVARIABLE NAME BETWEEN1 TO 8.
üVARIABLE FIRST LETTER ALWAYS ALPHABATIC.
üNOT ONLY COMMA (,) ALSO SPACE BETWEEN VARIABLE NAME NOT ALLOWED.
üEXAMPLE-NAME, S_NO, R_NO.
üNOT USE 32 KEYWORDS IN VARIBLE NAME.
üAFTER ANY STATEMENT USE SEMICOLON (;).


HEADER FILES:-
ALWAYS START PROGRAMME WITH THESE HEADER FILES.
                                      #INCLUDE<STDIO.H>

                        #INCLUDE<CONIO.H>

MAIN FUNCTION:-
                   ALL PROGRAM HAVE A FUNCTION WHICH IS
                                      VOID MAIN ()


          OPENING CURLEY BRACE-:
AFTER VOID MAIN YOU TYPE ALL STATEMNT IN OPENING CURLEY BRACE.      {

          DATA TYPE-:
WHAT KIND OF VARIBLE YOUR PROGRAMME REQUIRED THESE ARE
          INT, CHAR, FLOAT.

         
          VARIBLE-:
YOUR PROGRAMME REQUIRED VARIABLE WHICH IS RELATED FROM DATA TYPES.


          CLRSCR ()-:
                             CLEAR LAST RESULT FROM SCREEN.


          INPUT/OUTPUT-:
PRINTF () - IS USE FOR OUTPUT THE RESULT ON SCREEN.
SCANF () – IS USE FOR INPUTTING VALUE, CHARACTAR ETC.


          GETCH ()-:
                             GET ONE BY ONE CHARACTAR FOR PROCESSING.

CLOSING CURLEY BRACE-:
AFTER GETCH PROGRAMME CLOSED BY CLOSING CURLEY BRACE         }

1./* Write a program to addition*/

#include<stdio.h>
#include<conio.h>
main()
{
            int a,b,tot;
            clrscr();
            printf("ENTER NO.1:- ");
            scanf("%d",&a);
            printf("ENTER NO.2:- ");
            scanf("%d",&b);
            tot=a+b;
            printf("\n\ttotal=%d",tot);
            getch();
}


OUTPUT

            ENTER NO.1:10
            ENTER NO.2:10
                        TOTAL=20



2. /* Write a program to subtraction */

#include<stdio.h>
#include<stdio.h>
main()
{
int a,b,sub;
clrscr();
printf("ENTER NO.A:-");
scanf("%d",&a);
printf("ENTER NO.B:-");
scanf("%d",&b);
sub=a-b;
printf("\n\t sub=%d",sub);
getch();
}


OUTPUT

            ENTER NO. A:20
            ENTER NO. B:10
                        SUB=10

3./*Write a program to multiplication*/

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,mult;
clrscr();
printf("ENTER NO.A:-");
scanf("%d",&a);
printf("ENTER NO.B:-");
scanf("%d",&b);
mult=a*b;
printf("\n\t mult=%d",mult);
getch();
}


OUTPUT
            ENTER NO A:15
            ENTER NO B:10
                        MULT=150



4./*Write a program to division */

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,div;
clrscr();
printf("ENTER NO.A:-");
scanf("%d",&a);
printf("ENTER NO.B:-");
scanf("%d",&b);
div=a/b;
printf("\n\t division=%d",div);
getch();
}


OUTPUT
            ENTER NO A:20
            ENTER NO B:4
            DIVISION=5


5./* Write a program to addition,subtraction,multiplication,divition*/

#include<stdio.h>
#include<conio.h>
main()
{
            int a,b,add,sub,mult,div;
            clrscr();
            printf("ENTER NO.A:-");
            scanf("%d",&a);
            printf("ENTER NO.B:-");
            scanf("%d",&b);
            add=a+b;
            sub=a-b;
            mult=a*b;
            div=a/b;
            printf("Add=%d\nSub=%d\nMult=%d\nDiv=%d",add,sub,mult,div);
            getch();
}


OUTPUT
            ENTER NO A:20
            ENTER NO B:5
            ADD=25
            SUB=15
MULT=100
DIV=4


6./*Write a program to input a character and find out his ASCII value*/

#include<stdio.h>
#include<conio.h>
main()
{
char ch='A';
clrscr();
printf("\n The Character is:%c",ch);
printf("\n The ASCII value of this character is:%d",ch);
getch();
}


OUTPUT
            The Character is : A
            The ASCII value is this character is:65

7./*Write a program to Exchange  to value without use third variable*/

#include<stdio.h>
#include<conio.h>
main()
{
int a,b;
clrscr();
printf("\n ENTER VALUE A:-");
scanf("%d",&a);
printf("\n ENTER VALUE B:-");
scanf("%d",&b);
a=a+b;
b=a-b;
a=a-b;
printf("\n a=%d,b=%d",a,b);
getch();
}


OUTPUT
            ENTER VALUE A:10
            ENTER VALUE B:15
            A=15,B=10


8./*Write a program to Exchange two value use third variable*/

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf("\n ENTER VALUE A:-");
scanf("%d",&a);
printf("\n ENTER VALUE B:-");
scanf("%d",&b);
c=a;
a=b;
b=c;
printf("\n a=%d,b=%d",a,b);
getch();
}
OUTPUT
            ENTER VALUE A:12
            ENTER VALUE B:28
            A=28,B=12

9./*Write a program to findout area and circle*/

#include<stdio.h>
#include<conio.h>
void main()
{
float r,area,cir;
clrscr();
printf("Enter The Redius Of Circle:-");
scanf("%f",&r);
area=3.14*r*r;
cir=2*3.14*r;
printf("\n The area is:-%.2f");
printf("\n The circumference is:-%.2f",cir);
getch();
}


OUTPUT
            Enter The Redius Of Circle:1
            The area is:49.92
            The circumference is:6.28


10./*Write a program to find out area and parameter */

#include<stdio.h>
#include<conio.h>
main()
{
int l,w,a,p;
clrscr();
printf("\n ENTER LENTH:-");
scanf("%d",&l);
printf("\n ENTER WEIGHT:-");
scanf("%d",&w);
a=l*w;
printf("\n area=%d",a);
p=2*(l+w);
printf("\n perameter=%d",p);
getch();
}

OUTPUT
            ENTER LENTH:10
            ENTER WEIGHT:5
            Area=50
            Parameter =30

11./*Write a program to calculate simple interest*/ 

#include<stdio.h>
#include<conio.h>
main()
{
float a,b,c,d;
clrscr();
printf("Enter The Principal:-");
scanf("%f",&a);
printf("\n Enter The Rate:-");
scanf("%f",&b);
printf("\n Enter The Time:-");
scanf("%f",&c);
d=(a*b*c)/100;
printf("\n Interest is:-%f",d);
getch();
}


OUTPUT
            Enter The Principal:10000
            Enter The Rate:6
            Enter The Time:2
            Interest is:1200.00



12./*Write a program to Fahrenheit temperature to convert in degree Celsius*/

#include<stdio.h>
#include<conio.h>
main()
{
float ftemp,ctemp;
clrscr();
printf("The Temperature in Fahrenheit :-");
scanf("%f",&ftemp);
ctemp=5*(ftemp-32)/9;
printf("The Temperature in Degree Celsius is:-%f",ctemp);
getch();
}


OUTPUT
            The Temperature in Fahrenheit:98.4
            The Temperature in Degree Celsius is:36.888889


13./*Enter the temperature in Fahrenheit and convert into centigrade*/

#include<stdio.h>
#include<conio.h>
main()
{
float f,a;
clrscr();
printf("\n ENTER VALUE F:-");
scanf("%f",&f);
a=f-32/1.8;
printf("\n centigrade=%f",a);
getch();
}



OUTPUT
            ENTER VALUE F :98.4
            Centigrade=80.622223




14./*Write a program convert float to int*/

#include<stdio.h>
#include<conio.h>
main()
{
float x,y,z;
clrscr();
x=10.898;
y=21.777;
z=x+y;
printf("\n %f",z);
z=(int)x+y;
printf("\n %f",z);
z=(int)(x+y);
printf("\n %f",z);
getch();
}


OUTPUT
            32.674999
            31.777000
            32.000000

15./*Write a program to input students number and find out average*/

#include<stdio.h>
#include<conio.h>
main()
{
int boys,girls;
float avg;
clrscr();
printf("\n Enter The BOYS:-");
scanf("%d",&boys);
printf("\n Enter The GIRLS:-");
scanf("%d",&girls);
avg=(boys+girls)/2;
printf("\n AVERAGE:-%f",avg);
getch();
}


OUTPUT
            Enter The BOYS :34
            Enter The GIRLS :43
            AVERAGE=38
            AVERAGE=38.500000



16./*Write a program to input the distance in kilometers and convert it in                  meter*/


#include<stdio.h>
#include<conio.h>
main()
{
long int distkm,distmeter=0;
clrscr();
printf("Enter the distance in kilometers:-");
scanf("%ld",&distkm);
distmeter=distkm*1000;
printf("\n The distance in meters is:-%ld",distmeter);
getch();
}

OUTPUT
            Enter the distance in kilometers:25
            The distance in meters is: 25000

17./*Write a program to input three values and find out the Biggest number*/

#include"stdio.h"
#include"conio.h"
main()
{
int x,y,z,a,b;
clrscr();
printf("Enter Three Numbers:\n");
scanf("%d%d%d",&x,&y,&z);
a=x>y?x:y;
b=a>z?a:z;
printf("\n The Biggest Number is:%d",b);
getch();
}


OUTPUT
            Enter Three Numbers:
            582
            256
            566
            The Biggest Number is:582
           


18./*Write a program to use of pre increment operators */

#include<stdio.h>
#include<conio.h>
main()
{
int x,y;
clrscr();
x=5;
y=++x;
printf("\n The Value of X is:-%d",x);
printf("\n The Value of Y is:-%d",y);
getch();
}



OUTPUT
            The Value of X is:13
            The Value of Y is:13
           

19./*Write a program to use of post increment operator*/

#include<stdio.h>
#include<conio.h>
main()
{
int x,y;
clrscr();
x=5;
y=x++;
printf("\n The Value of X is:-%d",x);
printf("\n The Value of Y is:-%d",y);
getch();
}



OUTPUT
            The Value of X is:6
            The Value of Y is:5



20./*Write a program to use of main pre increment operators*/

#include<stdio.h>
#include<conio.h>
main()
{
int x,y;
clrscr();
x=5;
y=++x + ++x;
printf("\n The Value of X is:-%d",x);
printf("\n The Value of Y is:-%d",y);
getch();
}



OUTPUT
            The Value of X is:7
            The Value of Y is:14





21./*Write a program to use of main post increment operators*/

#include<stdio.h>
#include<conio.h>
main()
{
int x,y;
clrscr();
x=20;
y=x+++x++;
printf("\n THE Value of X is:-%d",x);
printf("\n THE Value of Y is:-%d",y);
getch();
}


OUTPUT
            The Value of X is:7
            The Value of Y is:10


22./*Write a program to input marks and find out percentage */

#include<stdio.h>
#include<conio.h>
main()
{
int m1,m2,m3,m4,m5;
long int tot;
float per;
clrscr();
printf("Enter the marks of a student in five subjects:-");
scanf("\n\n %d%d%d%d%d",&m1,&m2,&m3,&m4,&m5);
tot=m1+m2+m3+m4+m5;
per=(tot*100)/500;
printf("\n percentage of the student:-%f",per);
getch();
}


OUTPUT
            Enter the marks of a student is subjects:-45 45 45 45 45
            Percentage of the student:- 45.00







IF CONDITIONAL  


23./*Write a program to input number and find out Even and Odd*/

#include<stdio.h>
#include<conio.h>
main()
{
int a;
clrscr();
printf("Enter A Number:");
scanf("%d",&a);
if(a%2==0)
{
printf("This is A Even Number");
}
else
{
printf("This is A Odd Number");
}
getch();
}

OUTPUT
            Enter A Number:4
            This is A Even Number

24./*Write a program to input character and find out capital and small  consonants or vowel*/

#include<stdio.h>
#include<conio.h>
main()
{
            char ch;
            clrscr();
            printf("Enter a character");
            scanf("%c",&ch);
            if(ch>='A' && ch<='Z')
            if(ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U')
            printf("capital Vowel");
            else
            printf("Capital consonants");
            else
            if(ch>='a' && ch<='z')
            if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
            printf("small vowel");
            else
            printf("small consonants");
            getch();
}
OUTPUT
            Enter a character: a  small vowel

25./*Write a program to input two values and find out Greater value*/

#include<stdio.h>
#include<conio.h>
main()
{
int a,b;
clrscr();
printf("Enter First Value:");
scanf("%D",&a);
printf("Enter Second Value:");
scanf("%d",&b);
if(a>b)
{
printf("Greater Value is %d",a);
}
else
{
printf("Greater Value is %d",b);
}
getch();
}


OUTPUT
            Enter First Value:4
            Enter Second Value:7
            Greater Value is : 7



26./*Write a program to division of small value*/

#include<stdio.h>
#include<conio.h>
void main()
{
float a,b;
clrscr();
printf("enter the value a");
scanf("%f",&a);
printf("enter the value b");
scanf("%f",&b);
if (a>b)
printf("%f",a/b);
else
printf("%f",b/a);
getch();
}


OUTPUT
            Enter the value a:10
            Enter the value b:5
            2.0000



27./*Write a program to input your three subject marks and find out :-
                                      Marks>=60                             First Division
                                                Marks>=48&&Marks<60                Second Division                                                  Marks>=36&&Marks<48                Third Division                                                     Marks<36                                         Fail                                                                       Your Total , Your Percentage ?
#include<stdio.h>
#include<conio.h>
main()
{
            int m1,m2,m3,t;
            float p;
            clrscr();
            printf("Enter Marks 1:");
            scanf("%d",&m1);
            printf("Enter Marks 2:");
            scanf("%d",&m2);
            printf("Enter Marks 3:");
            scanf("%d",&m3);
            t=m1+m2+m3;
            p=t*100/300;
            printf("\nYour total=%d",t);
            printf("\nyour per=%f\n",p);
            if(p>=60)
            printf("First Division");
            if(p>=48&&p<60)
            printf("Second Division");
            if(p>=36&&p<48)
            printf("Third Division");
            if(p<36)
            printf("Fail");
            getch();
}


OUTPUT

            Enter Marks 1:45
            Enter Marks 2:56
            Enter Marks 3:78
           
            Your total=179

            Your per=59.0000
            Second Division










28/*Write a program to input your three subject marks and find out these:-
                                      Marks>=60                             First Division
                                      Marks>=48&&Marks<60                Second Division
                                      Marks>=36&&Marks<48                Third Division

#include<stdio.h>
#include<conio.h>
main()
{
int m1,m2,m3,p;
clrscr();
printf("Enter Msrks 1:");
scanf("%d",&m1);
printf("Enter Marks 2:");
scanf("%d",&m2);
printf("Enter Marks 3:");
scanf("%d",&m3);
p=(m1+m2+m3)*100/300;
            {
            if(p>=60)
            printf("First Division");
            else
            if(p>=48&&p<60)
            printf("Second Division");
            else
            if(p>=36&&p<48)
            printf("Third Division");
            else
            printf("Fail");
             }
getch();
}



OUTPUT


            Enter Marks 1:45
            Enter Marks 2:56
            Enter Marks 3:79

            Second Division







29./*Write a program to input a word and find out it is a Capital letter ,Small letter ,Decimal Number and a Special Character*/       

#include<stdio.h>
#include<conio.h>
main()
{
            char d;
            clrscr();
            printf("\n Type ");
            scanf("%c",&d);

            if(d>=65 && d<=90)
            printf("A word is capital latter");
            else
            if(d>=97 && d<=122)
            printf("A word is small latter");
            else
            if(d>=48 && d<=59)
            printf("A word is decimal number");
            else
            printf("is a special charactor");
            getch();
}

OUTPUT
            Type ANAND
            A word is capital latter

30/*Write a program to input a Character and find out it is a Alphabate , Numeric and a Special Symbol*/

#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
clrscr();
printf("Enter a charactar");
scanf("%c",&ch);
if(ch>='A'&& ch<='Z' || ch>='a'&& ch<='z')
printf("Alphabate");
else
if (ch>='0'&&ch<='9')
printf("numeric");
else
printf("special.symbol");
getch();
}

OUTPUT
            Enter a character ANAND
            Alphabet
           

31./*Write a program to input your Basic Salary and find out Allowance, Deduction and Net Salary*/

#include<stdio.h>
#include<conio.h>
main()
{
int bs,al,de,ns;
char g;
clrscr();
printf("Enter Your Salary:");
scanf("%d",&bs);
al=(25*bs)/100;
de=(bs+al)/100*10;
ns=(bs+al)-de;
printf("Your Basic Salary is: %d",bs);
printf("\n your Allowance is: %d",al);
printf("\n Your Deduction is: %d",de);
printf("\n Your Net Salary is: %d",ns);
if(ns>=15000)
printf("\n Grade: A");
if(ns<15000&&ns>10000)
printf("\n Grade: B");
if(ns<10000&&ns>5000)
printf("\nGrade: C");
if(ns<5000)
printf("\n Grade: D");
getch();
}



OUTPUT
            Enter Your Salary=5000

            Your Basic Salary is:5000

            Your Allowance is:-60

            Your Deduction is:490

            Your Net Salary is:4450

            Grade :D
           










32/*Write a program to input a Year and find out it is a Leep year or not*/

#include<stdio.h>
#include<conio.h>
main()
{
int year;
clrscr();
printf("Enter The Year:");
scanf("%d",&year);
if((year%4==0)&&(year%100!=0)||(year%400==0))
{
printf("\n Year %d is A Leep Year",year);
}
else
{
printf("\n Year %d is Not A Leep Year",year);
}
getch();
}


OUTPUT
            Enter The Year: 2004
            Year 2004 is A Leep Year
           

33./*Write a program to input your Qualification , Experience , Age and find out you are Eleigibal or not*/

#include<stdio.h>
#include<conio.h>
main()
{
            char q,e,s;
            int age;
            clrscr();
            scanf("Qualification=%c",&q);
            scanf("Experiance=%cSex=%c",&e,&s);
            scanf("Age=%d",&age);
            if(q=='m' && e<=10 && age<=40 && s=='m')
            printf("Eleigibal");
            else
            if(q=='m' && e<=10 && age<=40 && s=='f')
            printf("Eleigibal");
            else
            printf("Not eleigibal");
            getch();
}



34/*Write a program to find out policy amount or not*/

#include<stdio.h>
#include<conio.h>
main()
{
            char h,l,s,b=0,m=0;
            float pa,p;
            int a;
            clrscr();
            scanf("%c%c%c",&h,&l,&s);
            scanf("%f%f",&pa,&p);
            scanf("%d",&a);
            if(h<=25 && h<=35)
            printf("health is excellent");
            if(l==b)
            printf("lives in bikaner");
            else
            if(s==m)
            printf("sex is the male");
            else
            printf("sex is female");
            pa=pa<=200000;
            pa=p*4/1000;
            printf("%f",p);
            printf("polocey amount");
            printf("invalid policy amount");
            getch();
}

35/*Write a program to find out the Greater value*/

#include<stdio.h>
#include<conio.h>
main()
{
int a,b;
clrscr();
printf("Enter First Value:");
scanf("%D",&a);
printf("Enter Second Value:");
scanf("%d",&b);
if(a>b)
{
printf("Greater Value is %d",a);
}
else
{
printf("Greater Value is %d",b);
}
getch();
}

FOR LOOP 



36/*Write a program to find out the Factorial Number*/

#include<stdio.h>
#include<conio.h>
void main()
{
long int fact=1,num,i;
clrscr();
printf("ENTER A NUMBER:");
scanf("%ld",&num);
for(i=num;i>0;i--)
{
fact=fact*i;
}
printf("The Factorial Value for %ld is %ld",num,fact);
getch();
}


OUTPUT
            ENTER A NUMBER:4
            Factorial Value for 4 is 24



37./*Write a program to print this Fibonacci Series :-
          0,1,1,2,3,5,8,13,21,34

#include<stdio.h>
#include<conio.h>
main()
{
int x=0,y=1,z=0;
int i;
clrscr();
for(i=0;i<10;i++)
{
printf("%d,",z);
x=y;
y=z;
z=x+y;
}
getch();
}


OUTPUT
            0,1,1,2,3,5,8,13,21,34





38/*Write a program to print your name*/

#include<stdio.h>
#include<conio.h>
main()
{
int a;
clrscr();
for(a=0;a<10;a++)
{
printf("\n HELLO RAM");
break;
}
getch();
}         


OUTPUT

            HELLO RAM



39/*Write a program to print Ten Numbers and find out the Highest Number*/

#include<stdio.h>
#include<conio.h>
main()
{
int i,num,temp=0;
clrscr();
printf("Enter The Ten Numbers:\n");
scanf("%d",&num);
for(i=0;i<=10;i++);
{
scanf("%d",&num);
if(temp<num)
temp=num;
printf("\nThe Highest Number is:%d",temp);
}
getch();
}


OUTPUT
            Enter The Ten Numbers:
            1 54 2 6 8 9 7 12 5 6
            The Highest Number is: 54







40./*Write a program to print Ten Numbers and find out its Total*/

#include<stdio.h>
#include<conio.h>
main()
{
int i,num;
int sum=0;
clrscr();
printf("\nEnter Ten Numbers:");
for(i=0;i<10;i++)
{
scanf("%d",&num);
sum=sum+num;
}
printf("\n The Sum of Entered Numbers is:%d",sum);
getch();
}


OUTPUT
            Enter Ten Numbers:11 21 31 41 51 61 71 81 91 101
            The Sum of Entered Number is:560



41/*Write a program to print Odd Numbers*/

#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
for(i=0;i<100;i=i+2)
{
printf("%d",i+1);
printf("\t");
}
getch();
}


OUTPUT
            1 3 5 7 9 11 13 15 17 19………….99






42./*Write a program to print this Series :-
                      1 2 3 4 5 6 7 ………..20

#include<stdio.h>
#include<conio.h>
main()
{
int i;
clrscr();
for(i=1;i<=20;i++)
printf("\n %d",i);
getch();
}

OUTPUT
            1 2 3 4 5 6 7…….20


43./*Write a program to print this Series :-
                      1 3 5 7 9………….20

#include<stdio.h>
#include<conio.h>
main()
{
int i;
clrscr();
for(i=1;i<=20;i=i+2)
printf("\n %d",i);
getch();
}

OUTPUT
            1 3 5 7 9 ………19


44./*Write a program to print a table or even*\
#include<stdio.h>
#include<conio.h>
main()
{
int a;
clrscr();
for(a=2;a<=20;a=a+2)
printf("\n%d",a);
getch();
}

OUTPUT
            2 4 6 8 …………………20


45./*Write a program to print ten numbers by user*/

#include<stdio.h>
#include<conio.h>
main()
{
int i,n;
clrscr();
printf("Enter The No.:-");
scanf("%d",&n);
for(i=1;i<=n;i++)
printf("%d",i);
getch();
}

OUTPUT
            Enter The No.:10
            1 2 3 4 5 6 7 8 9 10

46./*Write a program to print this Series :-
        AaBbCcDd……………Zz

#include<stdio.h>
#include<conio.h>
main()
{
int a,b;
clrscr();
for(a=65;a<=90;a++)
printf("%c%c",a,a+32);
getch();
}

OUTPUT
            AaBbCcDd………….Zz

47./*Write a program to print Alphabate*/

#include<stdio.h>
#include<conio.h>
main()
{
int a;
clrscr();
for(a=65;a<=90;a++)
printf(" %c",a);
getch();
}

OUTPUT
            ABCD……….Z



48./*Write a program to print ASCII values*/

#include<stdio.h>
#include<conio.h>
main()
{
int a;
clrscr();
for(a=65;a<=90;a++)
printf(" %d",a);
getch();
}

OUTPUT
            65 66 67 68 …………. 90



49./*Write a program to print Binary to Decimal numbers*/

#include<stdio.h>
#include<conio.h>
main()
{
long int num;
long int rem,dig,sum=0,i,x=1;
clrscr();
printf("Enter a Binary Number:");
scanf("%ld",&num);
for(i=num;i>0;i=i/10)
{
rem=i%10;
dig=rem*x;
sum=sum+dig;
x=x*2;
}
printf("\nBinary Number is %ld\n\nDecimal Number is %ld",num,sum);
getch();
}

OUTPUT
            Enter a Binary Number :1111
            Binary Number is 1111
            Decimal Number is 15












50./*Write a program to print Decimal to Binary number*/

#include<stdio.h>
#include<conio.h>
void main()
{
long int num;
long int rem,bn=0,i,x=1,j;
clrscr();
printf("Enter a Decimal Number:");
scanf("%ld",&num);
for(i=num,j=0;i>0;i=i/2,j++)
{
rem=i%2;
bn=bn+rem*x;
x=x*10;
printf("\nIn %d pass the value of\n",j+1);
printf("variable rem is= %ld bn is %ld x is= %ld\n",rem,bn,x);
}
printf("\n\nFinal Output:\n\n\n");
printf("\nDecimal Number is %ld\n\nBinary Number is %ld",num,bn);
getch();
}


OUTPUT
            Enter a Decimal Number:15
            Decimal Number is 15
            Binary Number is 1111


51./*Write a program to print this Series :-
             12345……….80

#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int i;
clrscr();
for(i=1;i<=80;i++)
printf("%d",i);
getch();
}


OUTPUT
            12345……….80


52./*Write a program to print the ten numbers CUBE*/

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

OUTPUT
            1 8 27 64 125 216 343 512 729 1000


53./*Write a program to print Decrement order*/

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

OUTPUT
            25 24 23 22 21 …………………… 3 2 1

54./*Write a program to print Even numbers*/

#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
for(i=0;i<100;i=i+2)
{
printf("%d",i+2);
printf("\t");
}
getch();
}

OUTPUT
            2 4 6 8 10 ………………… 100


55./*Write a program to print sum of the Digits*/

#include<stdio.h>
#include<conio.h>
void main()
{
long int num,i;
int dig,sum=0;
clrscr();
printf("Enter a Number:");
scanf("%ld",&num);
for(i=num;i>0;i=i/10)
{
dig=i%10;
sum=sum+dig;
}
printf("\n The Sum of The Digits %ld is %d",num,sum);
getch();
}

OUTPUT
            Enter a Number: 12
            The Sum of The Digits 12 is 3


56./*Write a program to print this Series :-

#include<stdio.h>
#include<conio.h>
main()
{
int n,i,j;
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
getch();
}

OUTPUT
            1
            1 2
            1 2 3
            1 2 3 4
            1 2 3 4 5
           



57./*Write a program to print this Series by user :-

#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j;
clrscr();
printf("Enter How Many Lines You Want IN This Figure:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
getch();
}


OUTPUT
            Enter How Many Lines You Want IN This Figure:4
            1
            1 2
            1 2 3
            1 2 3 4


58./*Write a program to print this Series :-

 A C E G I K M O Q S U W Y

#include<stdio.h>
#include<conio.h>
main()
{
int i;
clrscr();
for(i=65;i<=90;i=i+2)
printf("%c%c",i,i+33);
getch();
}


OUTPUT
            A C E G I K M O Q S U W Y





59./*Write a program to print the reverse number.*/

#include<stdio.h>
#include<conio.h>
main()
{
            long int num,i;
            int dig;
            clrscr();
            printf("\n Enter the number:-");
            scanf("%ld",&num);
            printf("\n The reverse of number %ld is:-",num);
            for(i=num;i>0;i=i/10)
            {
            dig=i%10;
            printf("%d",dig);
            }
            getch();
}

OUTPUT
            Enter the number: 1 2 3 4 5
            The reverse of number 1 2 3 4 5 is: 5 4 3 2 1

60./*Write a program to print a trangle.*/

#include<stdio.h>
#include<conio.h>
main()
{
int n,i,j;
clrscr();
printf("Enter How Many Lines You Want In This Figure:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}

OUTPUT
            Enter How Many Lines You Want In This Figure:5
            *
            * *
            * * *
            * * * *
            * * * * *
61./*Write a program to print this series.*/

#include<stdio.h>
#include<conio.h>
main()
{
int n,i,j;
clrscr();
printf("Enter How Many Lines You Want:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",i);
}
printf("\n");
}
getch();
}

OUTPUT
            Enter How Many Lines You Want:5
            1
            2 2
            3 3 3
            4 4 4 4
            5 5 5 5 5

62./*Write a program to print this series.*/

#include<stdio.h>
#include<conio.h>
main()
{
int n,i,j;
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",i);
}
printf("\n");
}
getch();
}

OUTPUT
            1
            2 2
            3 3 3
            4 4 4 4
            5 5 5 5 5
63./*Write a program to print series 1,4,7,10,…100.*/

#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
for(a=0;a<100;a=a+2)
{
printf("%d",a=a+1);
printf("\t");
}
getch();
}

OUTPUT
            1 4 7 10 13 16 19 ……………. 100

64./*Write a program to print series*/
            0,3,8,15,24,35,48,63,80,99.

#include<stdio.h>
#include<conio.h>
main()
{
int i;
clrscr();
for(i=1;i<=10;i++)
{
printf("%d,",i*i-1);
}
getch();
}

OUTPUT
            0,3,8,15,24,35,48,63,80,99

65./*Write a program to print alphabets in small letter.*/

#include<stdio.h>
#include<conio.h>
main()
{
int a;
clrscr();
for(a=97;a<=122;a++)
printf("%c",a);
getch();
}

OUTPUT
            a b c d e f g h i j k l m n o p q r s t u v  w x y z


66./*Write a program to print a triangle.*/ 
#include<stdio.h>
#include<conio.h>
main()
{
int num,i,j,k,l;
clrscr();
printf("Enter The Number:");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
for(j=1;j<=num;j++)
{
printf("");
}
for(k=1;k<=i;k++)
{
printf("*");
}
for(l=1;l<i;l++)
{
printf("*");
}
printf("\n");
}
getch();
}

OUTPUT
            Enter The Number: 5
            *
            ***
            *****
            *******
            *********

67./*Write a program to to print a star by define spaces enter b user.*/

#include<stdio.h>
#include<conio.h>
main()
{
int i,sp;
clrscr();
printf("Enter Number of Spaces:-");
scanf("%d",&sp);
for(i=1;i<=sp;i++)
printf(" ");
printf("*");
getch();
}
 Enter Number of spaces:- 10

68./*Write a program to print square of given value by user.*/

#include<stdio.h>
#include<conio.h>
main()
{
            int num,sqr,i,max;
            clrscr();
            printf("Enter The Value;");
            scanf("%d",&num);
            max=num+10;
            for(i=num;i<max;i++)
            {
            sqr=num*num;
            printf("\n\t%d SQUARE=%d",i,sqr);
            num=num+1;
            }
            getch();
}

OUTPUT
            Enter The Value: 5
            5 SQUARE = 25
            6 SQUARE = 36
            7 SQUARE = 49
            8 SQUARE = 64
            9 SQUARE = 81
            10 SQUARE = 100
            11 SQUARE = 121
            12 SQUARE = 144
            13 SQUARE = 169
            14 SQUARE = 196

69./*Write a program to print the square of given numbers.*/
#include<stdio.h>
#include<conio.h>
main()
{
int i,n;
clrscr();
for(i=1;i<=7;i++)
printf("\n%d",i*i);
getch();
}

OUTPUT
            1
            4
            9
            16
            25
            36
            49


70./*Write a program to print a triangle given value by user.*/


#include<stdio.h>
#include<conio.h>
main()
{
int i,j,k,l,n;
clrscr();
printf("Enter any value");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
for(j=1;j<=n-i;j++)
{
printf(" ");
}
for(k=1;k<=i;k++)
{
 printf("*");
}
for(l=1;l<i;l++)
{
printf("*");
}
printf("\n");
}
getch();
}


OUTPUT


            Enter any value: 5


                   *
                 ***
               *****
              *******
            *********     










71./*Write a program to print a triangle.*/

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=0;i<=10;i++)
{
for(j=0;j<i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}

OUTPUT
            *
            **
            ***
            ****
            *****

72./*Write a program to print a triangle.*/

#include<stdio.h>
#include<conio.h>
main()
{
int n,i,j;
clrscr();
printf("Enter The Number:");
scanf("%d",&n);
for(i=n+1;i>0;i--)
{
for(j=0;j<i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}

OUTPUT:-
            Enter The Number: 5
            *****
            ****
            ***
            **
            *
WHILE LOOP 


75./*Write a program to print this series:-
         1 3 5 7 9 11 13 15 17 19 21 23 25 ………… 99.*/

#include<stdio.h>
#include<conio.h>
main()
{
            int i=1;
            clrscr();
            while(i<=100)
            {
             printf("%d\t",i);
             i=i+2;
             }
             getch();
}

OUTPUT

           
            1 3 5 7 9 11 13 15 17 19 21 23 25 ………… 99

76./*Write a program to print sum of 1,2,…,10  number*/

#include<stdio.h>
#include<conio.h>
main()
{
            int i;
            int sum=0;
            clrscr();
            i=1;
            while(i<=10)
            {
             sum=sum+i;
             i++;
            }
            printf("\n The sum of numbers from 1 to 10 is:%d",sum);
            getch();
}


OUTPUT

            The sum of numbers from 1 to 10 is : 55








77./*Write a program to print square of input number given by user.*/

#include<stdio.h>
#include<conio.h>
main()
{
            int num,square;
            char ans='y';
            clrscr();
            while(ans=='y'||ans=='Y')
            {
             printf("Enter a number\n");
             scanf("%d",&num);
             square=num*num;
             printf("The square of %d is %d",num,square);
             printf("\nDo You wish to enter another number (y for yes):");
             fflush(stdin);
             scanf("%c",&ans);
             }
             getch();
 }


OUTPUT
           
            Enter a number : 7
            The square of 7 is 49
            Do You wish to enter another number (y for yes):

78./*Write a program to print fabonnaci series as fast range.*/

#include<stdio.h>
#include<conio.h>
main()
{
            int f=0,f1=1,f2=0,n;
            clrscr();
            printf("Enter fast range");
            scanf("%d",&n);
            while(f1<n)
            {
            printf("%d",f2);
            f=f1+f2;
            f1=f2;
            f2=f;
            }
            getch();
}
OUTPUT
            Enter fast range :
            0 1 1 2 3 5



79./*Write a program to print smallest in given 10 numbers.*/

#include<stdio.h>
#include<conio.h>
main()
{
            int num,i,temp;
            clrscr();
            i=0;
            printf("Enter A Number:");
            scanf("%d",&num);
            temp=num;
            while(i<9)
            {
             printf("\nEnter A Number:");
             scanf("%d",&num);
             if(temp>num)
             {
              temp=num;
              }
              i++;
              }
              printf("\n\nThe Smallest Number is:%d",temp);
              getch();
  }

OUTPUT

            Enter a number :  5
           
            Enter a number :  4
           
            Enter a number :  56

            Enter a number :  8

            Enter a number :  6

            Enter a number :  3

            Enter a number :  8

            Enter a number :  9     

            Enter a number :  10

            Enter a number :  23

            The Smallest Number is : 3






80./*Write a program to print sum of given digits by user.*/





#include<stdio.h>
#include<conio.h>
void main()
{
            int n, p=0,s,x=1,ct=0,sum=0;
            clrscr();
            printf("Enter The Number:");
            scanf("%d",&n);
            while(ct<n)
            {
            p=0;
            s=x;
            while(s>0)
            {
            p=(p*10)+(s%10);
            s=s/10;
            }
            if(x==p)
            {
            sum=sum+x;
            ct++;
            }
            x++;
            }
            printf("sum is: %d",sum);
            getch();
}



OUTPUT

            Enter The Number : 6
            Sum is : 21












81./*Write a program to print fabonnaci series of given number input by user.*/

#include<stdio.h>
#include<conio.h>
main()
{
            int f=0,f1=1,f2=0,n,i=0;
            clrscr();
            printf("Enter any value");
            scanf("%d",&n);
            while(i<n)
            {
             printf("%4d",f2);
             f=f1+f2;
             f1=f2;
             f2=f;
             i++;
             }
             getch();
 }

OUTPUT

            Enter any value: 5
            0 1 1 2 3

           
82./*Write a program to print Series by user*/

#include<stdio.h>
#include<conio.h>
main()
{
            int f=0,f1=1,f2=0,n;
            clrscr();
            printf("Enter fast range");
            scanf("%d",&n);
            while(f1<n)
            {
            printf("%d",f2);
            f=f1+f2;
            f1=f2;
            f2=f;
            }
            getch();
}

OUTPUT

            Enter fast range : 5
            0 1 1 2 3 5


83./*Write a program to print the triangle value*/

#include<stdio.h>
#include<conio.h>
main()
{
            int n,sum=0;
            clrscr();
            printf("Enter any value");
            scanf("%d",&n);
            while(n>0)
            {
            sum=sum+n;
            n--;
            }
            printf("Triangular value is %d",sum);
            getch();
}


OUTPUT

            Enter any value : 5

            Triangular  value is 15

84./*Write a program to a program N Triangular Number*/

#include<stdio.h>
#include<conio.h>
main()
{
            int n,i=1,sum=0;
            clrscr();
            printf("Enter any value");
            scanf("%d",&n);
            while(i<=n)
            {
             sum=sum+i;
             printf("N Triangular of %d is %d\n",sum);
             i++;
             }
             getch();
 }

OUTPUT

            Enter any value: 4
            N Triangular of 1 is 2400
            N Triangular of 3 is 2400
            N Triangular of 6 is 2400
            N Triangular of 10 is 2400



85./*Write a program to to print spaces*/


#include<stdio.h>
#include<conio.h>
main()
{
int i,sp;
clrscr();
printf("Enter The Number of Spaces:");
scanf("%d",&sp);
i=0;
while(i<=sp)
{
printf(" ");
i=i+1;
}
printf("*");
getch();
}


OUTPUT
            Enter The Number of Spaces: 5
                 *





























DO WHILE LOOP
 


 


86./*Write a program to print the sum of numbers from 1 to 10*/

#include<stdio.h>
#include<conio.h>
main()
{
            int i;
            int sum=0;
            clrscr();
            i=1;

            do
            {
             sum=sum+i;
             i++;
             }while(i<=10);
             printf("\nThe sum of numbers from 1 to 10 is:%d",sum);
             getch();
 }


OUTPUT

            The of numbers from 1 to 10 is: 55

87./*Write a program to print this Series*/

#include<stdio.h>
#include<conio.h>
main()
{
            int i=1;
            clrscr();
            do
            {
             printf("%d\t",i);
             i=i+2;
            }
            while(i<100);
            getch();
}


OUTPUT

            1 3 5 7 9 11 13 15 17 19 ………………. 99


ARRAY 

 


88./*Write a program to print a String*/
#include<stdio.h>
#include<conio.h>
main()
{
            char n[20];
            int j;
            clrscr();
            printf("Enter a string");
            gets(n);
            for(j=0;n[j]!='\0'; j++)
            {
             if(n[j]>=65 && n[j]<=90)
             printf("%c",n[j]+32);
             else
             if(n[j]>=97 && n[j]<=122)
             printf("%c",n[j]);
             }
             getch();
 }

OUTPUT
            Enter a string MAHESH
            tejkumar

89./*Write a program to copy of String*/
#include<stdio.h>
#include<conio.h>
main()
{
            char str1[100],str2[100];
            int i;
            clrscr();
            printf("Enter the string:");
            gets(str1);
            for(i=0;str1[i]!='\0';i++)
            {
             str2[i]=str1[i];
            }
            str2[i]='\0';
            printf("\n The Original string is:%s",str1);
            printf("\n The Copied string is: %s",str2);
            getch();
}

OUTPUT
            Enter the string: MAHESH
            The Original string is : MAHESH
            The Copied string is: MAHESH

90./*Write a program to print a String and a another String and connect it*/
#include<stdio.h>
#include<conio.h>
main()
{
            char string1[20],string2[20],string3[40];
            int i,j,k;
            int len=0;
            clrscr();
            printf("Enter a string:");
            gets(string1);
            printf("Enter Another string:");
            gets(string2);
            for(i=0;string1[i]!='\0';i++)
            {
             string3[i]=string1[i];
             len++;
            }
            for(j=len,k=0;string2[k]!='\0';j++,k++)
             {
              string3[j]=string2[k];
             }
            string3[j]='\0';
            printf("The concatenated string is:%s",string3);
            getch();
}

OUTPUT
            Enter a string:MAHESH
            Enter Another string: SOLANKI
            The concatenated string is : MAHESHSOLANKI

91./*Write a program to print a String and find out of its total Character*/

#include<stdio.h>
#include<conio.h>
main()
{
            char a[20];
            int j;
            clrscr();
            printf("Enter a string:");
            gets(a);
            for(j=0;a[j]!='\0';j++);
            {
             printf("\nTotal char=%d",j);
             }
             getch();
 }

OUTPUT
            Enter a string: TEJKUMAR SAHARAN
            Total char = 15


92./*Write a program to print a String of 3*3 matrics*/

#include<stdio.h>
#include<conio.h>
main()
{
int mat[3][3];
int i,j;
clrscr();
printf("Enter a 3 X 3 array:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&mat[i][j]);
}
}
printf("The array in the matrix form is\n");
for(i=0;i<3;i++)
{
printf("\n");
for(j=0;j<3;j++)
{
printf("MAT[%d][%d] =%d\t\t",i,j,mat[i][j]);
}
}
 getch();
}


OUTPUT
            Enter a 3 X 3 array:
            1
            2
            3
            4
            5
            6
            7
            8
            9
The array in the matrix form is
MAT[0][0]=1              MAT[0][1]=2              MAT[0][2]=3
MAT[1][0]=4              MAT[1][1]=5              MAT[1][2]=6
MAT[2][0]=7              MAT[2][1]=8              MAT[2][2]=9










93./*Write a program to print the elements in Array and find out maximum number*/

#include<stdio.h>
#include<conio.h>
void main()
{
int arr[10];
int i,temp;
clrscr();
printf("enter the elements in the array:\n");
for(i=0;i<10;i++)
{
scanf("%d",&arr[i]);
}
temp=arr[0];
for(i=1; i<10 ; i++)
{
if(temp<arr[i])
temp=arr[i];
}
printf("The maximum numbers : %d",temp);
getch();
}


OUTPUT


            Enter the elements in the array:
            4
            2         
            9
            6
            7         
            5
            8
            3
            2
            1

            The maximum number is: 9










94./*Write a program to merged Array*/
#include<stdio.h>
#include<conio.h>
#include<process.h>
main()
{
int array1[100],array2[100],array3[200];
int i,j,k;
int m,n,p;
clrscr();
printf("How many elements you want in first array:");
scanf("%d",&m);
if(m>100)
{
printf("Array out of bound, press any key to exit...");
getch();
exit(1);
}
printf("Enter %d elements in the first array:\n",m);
for(i=0;i<m;i++)
{
scanf("%d",&array1[i]);
}
printf("How many elements you want is second array:");
scanf("%d",&n);
if(n>100)
{
printf("Array out of bound,press any key to exit...");
getch();
exit(1);
}
printf("\nEnter %d elements for the second array:\n",n);
for(i=0;i<n;i++)
{
scanf("%d",&array2[i]);
}
for(i=0;i<m;i++)
{
array3[i]=array1[i];
}
for(j=m,k=0;k<n;k++,j++)
{
array3[j]=array2[k];
}
p=m+n;
printf("The merged array is\n");
for(i=0;i<p;i++)
{
printf("array3[%d]=%d\n",i,array3[i]);
}
getch();
 }



OUTPUT

            How many elements you want in first array : 4

            Enter 4 elements in the first array

            1
            3
            5
            7

            How many elements you want is second array : 4

            Enter 4 elements for the second array

            1
            2
            4
            6

            The merged array is

            array3[0] = 1
            array3[0] = 3
            array3[0] = 5
            array3[0] = 7
            array3[0] = 1
            array3[0] = 2
            array3[0] = 4
            array3[0] = 6
























95./*Write a program to print the elements Array and find out the minimum number*/

#include<stdio.h>
#include<conio.h>
void main()
{
int arr[10];
int i,temp;
clrscr();
printf("enter the elements in the array:\n");
for(i=0; i<10; i++)
{
scanf("%d",&arr[i]);
}
temp=arr[0];
for(i=1; i<10; i++)
{
if(temp>arr[i])
temp=arr[i];
}
printf("the minimum number is:%d",temp);
getch();
}



OUTPUT


            Enter the elements in the Array  :

            1
            5
            9
            4         
            3
            6
            4
            8
            2
            4

            The minimum number is  : 2










96./*Write a program to multiplication*/

#include<stdio.h>
#include<conio.h>.
main()
{
            int array[5],i;
            clrscr();
            printf("Enter an array:\n");
            for(i=0;i<5;i++)
            {
            scanf("%d",&array[i]);
            }
            for(i=0;i<5;i++)
            {
            array[i]=array[i]*7;
            }
            printf("\nThe array elements after multiplication are:\n");
            for(i=0;i<5;i++)
            {
            printf("%d\n",array[i]);
            }
            getch();
}


OUTPUT


            Enter an Array :

            2
            3
            4
            5
            6

            The array elements after multiplication are:

            14
            21
            28
            35
            42










97./*Write a program to length of String*/

#include<stdio.h>
#include<conio.h>
void main()
{
            char str[100];
            int len=0,i;
            clrscr();
            printf("Enter A String:");
            gets(str);
            for(i=0;str[i]!='\0';i++)
            {
            len++;
            }
            printf("The Lenth of The String is:%d",len);
            getch();
}


OUTPUT

            Enter A String: MAHESH SOLANKI
            The Length of The String is : 15

98./*Write a program to find out the character is positive or negetive*/

#include<string.h>
#include<stdio.h>
#include<conio.h>
main()
{
            char string[20];
            char *ptr,c;
            clrscr();
            printf("Enter A string:");
            gets(string);
            printf("Enter a character which u wish to check:");
            scanf("%c",&c);
            ptr=strchr(string,c);
            if(ptr)
             printf("The character %c is at position:%d\n",c,ptr-string+1);
            else
             printf("The character was not found\n");
             getch();
}

OUTPUT
            Enter A string: MAHESH
            Enter a character which u wish to check : A
            The character h is at position 7


99./*Write a program to print the reverse number*/

#include<stdio.h>
#include<conio.h>
main()
{
char str1[10];
int i,len=0,j;
clrscr();
printf("Enter the string:");
gets(str1);
for(i=0;str1[i]!='\0';i++)
{
len++;
}
printf("\n The reverse string is:");
for(j=len-1;j>=0;j--)
{
printf("%c",str1[j]);
}
getch();
}

OUTPUT
            Enter the string :MAHESH
            The reverse string is : HSWHAM

100./*Write a program to print a string and its change*/
#include<stdio.h>
#include<conio.h>
main()
{
char n[20];
int j;
clrscr();
printf("Enter a string");
gets(n);
for(j=0;n[j]!='\0';j++)
{
if(n[j]>=65 && n[j]<=90)
printf("%c",n[j]);
else
if(n[j]>=97 && n[j]<=122)
printf("%c",n[j]-32);
else
printf("%c",n[j]);
}
getch();
}

OUTPUT
            Enter a string : tejkumar saharan
            TEJKUMAR SAHARAN
101./*Write a program to print sorted array*/

#include<stdio.h>
#include<conio.h>
main()
{
            int array[10],i,j;
            int temp;
            clrscr();

            printf("Enter ten number:\n");
            for(i=0;i<10;i++)
            {
                        scanf("%d",&array[i]);
            }
            for(i=0;i<5;i++)
            {
            for(j=0;j<10;j++)
            {
            if(array[j]>array[j+1])
            {
            temp=array[j];
            array[j]=array[j+1];
            array[j+1]=temp;
            }
            }
            }
            printf("The sorted array is:\n");
            for(i=0;i<10;i++)
            {
            printf("%d\n",array[i]);
            }
            getch();
}

OUTPUT
            Enter ten number :
            4
            8
            2
            3
            4
            6
            1
            6
            2
            4
            The sorted array is :
            1
            2         
            2
            3
            4
            4


102./*Write a program to input first 3*3 array , second 3*3 array and find out its sum of matrics*/

#include<stdio.h>
#include<conio.h>
main()
{
int arr1[3][3],arr2[3][3],sum[3][3];
int i,j;
clrscr();
printf("Enter First 3 X 3 array:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&arr1[i][j]);
}
}
printf("Enter Second 3 X 3 array :\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&arr2[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
sum[i][j]=arr1[i][j]+arr2[i][j];
}
}
printf("The sum of the matrix is\n");
for(i=0;i<3;i++)
{
printf("\n");
for(j=0;j<3;j++)
{
printf("sum[%d][%d] = %d\t\t",i,j,sum[i][j]);
}
}
getch();
}












OUTPUT


            Enter first 3 X 3 array :

            1
            2
            3
            4
            5
            6
            7
            8
            9

            Enter second 3 X 3 array :

            1
            2
            3
            4
            5
            6
            7
            8
            9

            the sum of the matrix is

            sum[0][0] = 2              sum[0][1] = 4              sum[0][2] = 6 
            sum[1][0] = 8              sum[1][1] = 10            sum[1][2] = 12           
            sum[2][0] = 14            sum[2][1] = 16            sum[2][2] = 18           



















103./*Write a program to input two dimensional array of 4*4 and find out sum of his each Row    and Column and Forward & Backward sum*/

#include<stdio.h>
#include<conio.h>
main()
{
            int mat[4][4],a,j,i;
            int rtot=0,ctot,ftot=0,btot=0;
            clrscr();
            for(i=0;i<4;i++)
            {
            for(j=0;j<4;j++)
            {
            printf("Enter number:");
            scanf("%d",&a);
            mat[i][j]=a;
            }
            }
            printf("\n");
            for(i=0;i<4;i++)
            {
            for(j=0;j<4;j++)
            {
             printf("%d\t",mat[i][j]);
             rtot=rtot+mat[i][j];
             }
             printf("ROW TOTAL:%d",rtot);
             rtot=0;
             printf("\n");
             }
             printf("\n COLUMN TOTAL\n");
             for(j=0;j<4;j++)
             {
             ctot=0;
             for(i=0;i<4;i++)
             ctot=ctot+mat[i][j];
             printf("%d\t",ctot);
             }
             for(i=0;i<4;i++)
             ftot=ftot+mat[i][i];
             printf("\n\n\nFORWARD TOTAL:%d",ftot);
             i=0;
             btot=0;
             for(j=3;j>=0;j--)
             {
             btot=btot+mat[j][j];
             i++;
             }
             printf("\n\nBACKWARD TOTAL:%d",btot);
             getch();
 }


OUTPUT


            Enter number = 1
            Enter number = 2
            Enter number = 3
            Enter number = 4
            Enter number = 5
            Enter number = 6
            Enter number = 7
            Enter number = 8
            Enter number = 9
            Enter number = 10
            Enter number = 11
            Enter number = 12
            Enter number = 13
            Enter number = 14
            Enter number = 15
            Enter number = 16

            1          2          3          4          ROW TOTAL = 10
            5          6          7          8          ROW TOTAL = 26
            9          10        11        12        ROW TOTAL = 42
            13        14        15        16        ROW TOTAL = 58

            COLUMN TOTAL

            28        32        36        40

           
            FORWARD TOTAL : 34

                       
            BACKWARD TOTAL : 34



















104./*Write a program to input two dimensional array to convert Row to Column and Column to Row and print transpose value*/

#include<stdio.h>
#include<conio.h>
main()
{
int arr1[3][3],arrt[3][3];
int i,j;
clrscr();
printf("Enter a 3 X 3 array:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&arr1[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
arrt[i][j]=arr1[j][i];
}
}
printf("The transpose of the matrix is\n");
for(i=0;i<3;i++)
{
printf("\n");
for(j=0;j<3;j++)
{
printf("arrt[%d][%d] = %d\t\t",i,j,arrt[i][j]);
}
}
getch();
}

OUTPUT
            Enter a 3 X 3 array :
            1
            2
            3
            4
            5
            6
            7
            8
            9
            The transpose of the matrix is
            arrt[0][0] = 1               arrt[0][1] = 4               arrt[0][2] = 7
            arrt[1][0] = 2               arrt[1][1] = 5               arrt[1][2] = 8
            arrt[2][0] = 3               arrt[2][1] = 6               arrt[2][2] = 9



105./*Write a program to print the Character and find out how many Vowel & Constant in*/

#include<stdio.h>
#include<conio.h>
main()
{
            char n[20];
            int j,v=0,c=0,as;
            clrscr();
            printf("Enter charactor:-\n");
            gets(n);
            for(j=0;n[j]!='\0';j++)
            {
             as=n[j];
             if(as>=65 && as<=90)
             {
             if(n[j]=='A' || n[j]=='E' || n[j]=='I' || n[j]=='O' || n[j]=='U')
             v++;
             else
             c++;
             }
             }
             printf("Vowel=  %d\n Constant=  %d",v,c);
             getch();
 }


OUTPUT
            Enter character:-MAHESH SOLANKI
            Vowel = 6
            Constant = 9





















FUNCTION 




106./*Write a program to find out the Area*/

#include<stdio.h>
#include<conio.h>
void main()
{
int l,b,area;
clrscr();
printf("Enter Length:");
l=read();
printf("Enter breadth:");
b=read();
area=l*b;
printf("\nThe Area is:%d",area);
getch();
}
read(int a)
{
scanf("%d",&a);
return a;
}


107./*Write a program to use of function call by value*/

#include<stdio.h>
#include<conio.h>
main()
{
            int a;
            a=200;
            clrscr();
            printf("\na=%d",a);
            add(a);
            printf("\nAFTER RETURN FROM FUNCTION a=%d",a);
            getch();
            }
            add(int a)
            {
            a=a+200;
            printf("\nIN FUNCTION a=%d",a);
            return;
}

OUTPUT
            A = 200
            IN FUNCTION a = 400
            AFTER RETURN FROM FUNCTION a = 200


108./*Write a program to input the two number and find out the sum of two numbers*/

#include<stdio.h>
#include<conio.h>
void add();
main()
{
     clrscr();
     add();
     getch();
     }
     void add()
     {
     int x,y,sum;
     printf("Enter two numbers:\n");
     scanf("%d%d",&x,&y);
     sum=x+y;
     printf("\nThe sum of two numbers is: %d",sum);
}


109./*Write a program to find out the sum of two numbers use of two Argument*/

#include<stdio.h>
#include<conio.h>
int add(int,int);
void main()
{
int x,y,sum;
clrscr();
add(x,y);
printf("Enter two numbers:\n");
scanf("%d%d",&x,&y);
sum=add(x,y);
printf("The sum of two numbers is: %d",sum);
getch();
}
int add(int a,int b)
{
int c;
c=a+b;
return c;
}


OUTPUT
            Enter two numbers :
            5
            18
            The sum of two numbers is : 23





110./*Write a program to print the numbers of sum*/



#include"stdio.h"
#include"conio.h"
int sum(int,int);        /*function declaration*/
main()
{
int i=0,j=0,tot;
clrscr();
sum(i,j);                     /*function call*/
printf("Enter two value");
scanf("%d%d",&i,&j);
tot=sum(i,j);
printf("SUM=%d",tot);
getch();
}
int sum(int a,int b)               /*function defination*/
{
int u;
u=a+b;
return(u);
}



POINTER
 



111./*write a program to find address of integer and float number*/

#include<stdio.h>
#include<conio.h>
void main()
{
            int i,*iptr;
            float f,*fptr;
            clrscr();
            printf("Enter an integer number:");
            scanf("%d",&i);
            printf("Enter a float number:");
            scanf("%f",&f);
            iptr=&i;
            fptr=&f;
            printf("\nThe address of integer variable is %u",iptr);
            printf("\nThe value of integer variable is %d",i);
            printf("\nThe value of the integer variable using pointer is%d\n",iptr);
            printf("\nThe address of float variable is %u\n",fptr);
            printf("The value of float variable is %f\n",f);
            printf("The value of the float variable using pointer is%.2f\n",*fptr);
            getch();
}

OUTPUT
            Enter an integer number:55
Enter a float number:55.5

The address of integer variable is 65524
The value of integer variable is 55
The value of the integer variable using pointer is 55

The address of float variable is 65520
The value of float variable is 55.500000
The value of the float variable using pointer is 55.50

112./ Write a program to find memory veriable by using pointer*/

#include<stdio.h>
#include<conio.h>
void main()
{
            int x=10,y=20;
            char a='y',b='n';
            float p=90.76,q=75.43;
            clrscr();
            printf("\n%d is stored at address %u",x,&x);
            printf("\n%d is stored at address %u",y,&y);
            printf("\n%c is stored at address %u",a,&a);
            printf("\n%c is stored at address %u",b,&b);
            printf("\n%f is stored at address %u",p,&p);
            printf("\n%f is stored at address %u",q,&q);
            getch();
}

OUTPUT
            10 is stored at address 65524
            20 is stored at address 65522
            y is stored at address 65521
            n is stored at address 65520
            90.760002 is stored at address 65516
            75.430000 is stored at address 65512

113./*Write a program to show function call by reference*/

#include<stdio.h>
#include<conio.h>
void main()
{
            int a;
            a=200;
            clrscr();
            printf("\na = %d",a);
            add(&a);
            printf("\nAFTER RETURN FROM FUNCTION a=%d",a);
            getch();
            }
            add(int*ptr)
            {
            *ptr = *ptr+200;
            printf("\nIN FUNCTION a=%d",*ptr);
            return;
}

OUTPUT
            a = 200
            IN FUNCTION a= 400
            AFTER RETURN FROM FUNCTION a= 400

114./*Write a program to find operators by using pointer*/

#include<stdio.h>
#include<conio.h>
void main()
{
            int x,a,y,b,*ptr1,*ptr2,c,d;
            clrscr();
            printf("\nENTER AN INTEGER:");
            scanf("%d",&x);
            fflush(stdin);
            printf("\nENTER AN INTERGER:");
            scanf("%d",&y);
            ptr1=&x;
            ptr2=&y;
            a=*ptr1-*ptr2;
            b=*ptr1* *ptr2+8;
            printf("\na=%d\nb=%d",a,b);
            printf("\nx-y or *ptr1-*ptr2=%d",a);
            printf("\nx*y+8 Or *ptr1* *ptr2+8=%d",b);
            printf("\nAddress of x=%u",ptr1);
            printf("\nAddress of y=%u",ptr2);
            c= 5-*ptr2 / *ptr1-2;
            printf("\nc=%d",c);
            *ptr1=*ptr2-5;
            printf("\nx=%d",*ptr1);
            d=*ptr1* *ptr2 *6;
            printf("\nc=%d",d);
            getch();
}

OUTPUT
            ENTER AN INTEGER : 6

ENTER AN INTEGER : 3

a =3
b = 26
x-y Or *ptr1 – “ptr2=3
x*y + 8 Or *ptr1 * *ptr2 + 8 = 26
Address of x = 65524
Address of y= 65520
C = 3
X = -2
C = -36



STRUCTURE
 



115./*Write a program to print that all members of union storage location is one*/
#include<conio.h>
union math
{
int a,b;
}value;
void main()
{
clrscr();
printf("\n Enter Numer-A-:");
scanf("%d",&value.a);
printf("Firsst Time Value of A is:%d\n",value.a);
printf("\n Enter Number-B-:");
scanf("5d",&value.b);
printf("Now Value of A is:%d\nand Value of B is:%d",value.a,value.b);
getch();
}
OUTPUT
            Enter number-A-:4
            First Time Value of A is :4
            Enter Number-B-:Now Value of A is :7
            And Value of B is :7

116./* Write a program to print structure’s element pass in function*/

#include<stdio.h>
#include<conio.h>
main()
{
            struct student
            {
             int rollno;
             char name[40];
             };
              struct student s1;
              clrscr();
              printf("Enter roll number and name of the student;\n");
              scanf("%d%s",&s1.rollno,s1.name);
              display(s1.rollno,s1.name);
              getch();
              }
              display(int x,char *s)
              {
              printf("\nThe roll number of the student is:%d\n",x);
              printf("\nThe name of the student is:%s",s);
  }
OUTPUT
            Enter roll number and name of the student: 30 SYAM LAL
            The roll number of the student is: 30
            The name of the student is : SYAM LAL

117./*Write a program to print the records in structure variable by user*/

#include<stdio.h>
#include<conio.h>
struct data
{
int rno;
int marks;
char name[20];
};
void main()
{
struct data stu1;
clrscr();
printf("\n Enter Roll No.:");
scanf("%d",&stu1.rno);
printf("\n Enter Name:");
fflush(stdin);
gets(stu1.name);
printf("\n Enter Marks:");
scanf("%d",&stu1.marks);
printf("\n\n");
printf("\n\t Roll No.\tName\t\t Marks");
printf("\n%12d",stu1.rno);
printf("\t%15s",stu1.name);
printf("%12d",stu1.marks);
getch();
}


OUTPUT
            Enter Roll No. 30

            Enter Name:RAMKUMAR

            Enter Marks: 90

            Roll No.          Name                         Marks
            30                    RAMKUMAR                      90

118./*Write a program to use of structure’s members form of array*/

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

struct employee
{
int empno;
char name[20];
int age;
}
e[5];
void main()
{
int i;
clrscr();
printf("Enter details for five employees\n");
for(i=0;i<5;i++)
{
printf("\nEnter the employee number name and age for employee %d\n",i+1);
fflush(stdin);
scanf("%d%s%d",&e[i].empno,e[i].name,&e[i].age);
}
for(i=0;i<5;i++)
{
printf("\n\nThe details of employee %d\n",i+1);
printf("%d\t%s\t%d",e[i].empno,e[i].name,e[i].age);
}
getch();
}

OUTPUT
            Enter details for five employees
            Enter the employee number name and age for employee 1
            1MAHESH 23
            Enter the employee number name and age for employee 2
            2 raju 24
            Enter the employee number name and age for employee 3
            3 harish 22
            Enter the employee number name and age for employee 4
            4 SIKENDER 22
            Enter the employee number name and age for employee 5   
            5 SANDEEP 23
            The details of employee 1
            1          MAHESH       23
            The details of employee 1
            2          VIJAYKUMAR         24
            The details of employee 1
            3          harish   22
            The details of employee 1
            4          SIKENDER    22
            The details of employee 1
            5          SANDEEP      23

119./*Write a program to print the details of a student*/

#include<stdio.h>
#include<conio.h>
struct student
{
int rollno;
char name[20];
};
struct personal
{
int age;
char phone[10];
struct student s1;
};
void main()
{
struct personal p1;
clrscr();
printf("Enter roll number and name of the student:\n");
scanf("%d%s",&p1.s1.rollno,p1.s1.name);
printf("\nEnter age and phone number of the student :\n");
scanf("%d%s",&p1.age,p1.phone);
printf("\nThe roll number of the student is:%d",p1.s1.rollno);
printf("\nThe name of the student is:%s",p1.s1.name);
printf("\nThe age of the student is: %d",p1.age);
printf("\nThe phone number of the student is:%s\n",p1.phone);
getch();
}


OUTPUT
            Enter roll number and name of the student:
23                RAM KUMAR VARMA

Enter age and phone number of the student:
20                277458

The roll number of the student is: 23

The name of the student is: mahesh

The age of the student is: 20

The phone number of the student is: 277458

120./*Write a program to print the item,qty,price and multiplication of qty & price and find out his total value*/                  

#include<stdio.h>
#include<conio.h>
struct inv
{
            int item;
            int qty;
            int price;
};
void main()
{
int i,count;
struct inv item[10];
clrscr();
printf("\nEnter Number of Itema:");
scanf("%d",&count);
printf("\n");
for(i=0;i<count;i++)
{
printf("ITEM:QTY:PRICE:");
scanf("%d%d%d",&item[i].item,&item[i].qty,&item[i].price);
}
value(item,count);
getch();
}
value(cal,num)
struct inv cal[10];
int num;
{
int i;
int value;
printf("\n\n********S T O C K V A L U E**********\n");
printf("\nITEM\tQTY\tPRICE\t\tQTY *PRICE");
for(i=0;i<num;i++)
{
value=cal[i].qty*cal[i].price;
printf("\n%d\t%d\t%d\t\t%d",cal[i].item,cal[i].qty,cal[i].price,value);
}
return(0);
}

OUTPUT
            Enter Number of Item : 1
            ITEM:QTY:PRICE:1 2 10
            ITEM:QTY:PRICE:
           
            **************S T O C K V A L U E******************
            ITEM              QTY                PRICE            QTY*PRICE
            1                      2                      10                    20
            



121./*Write a program to print the name, roll no, and date of brith*/

#include<stdio.h>
#include<conio.h>
struct date
{
            int dd,mm,yy;
            clrscr();
            };
            struct student
            {
            int roll;
            char name[20];
            struct date dob;
            };
            void main()
            {
             struct student p;
             clrscr();
             printf("Enter name");
             gets(p.name);
             printf("Enter roll no.");
             scanf("%d",&p.roll);
             printf("Enter dd/mm/yy");
             scanf("%d%d%d",&p.dob.dd,&p.dob.mm,&p.dob.yy);
             printf("\nName is %s",p.name);
             printf("\nRoll No. is%d",p.roll);
             printf("\nDOB is %d/%d/%d",p.dob.dd,p.dob.mm,p.dob.yy);
             getch();
}

OUTPUT
            Enter name :mahesh
            Enter roll no. 23

            Enter dd/mm/yy. 02/21/87

            Name is mahesh
            Roll No. is 23

            DOB 02/21/87

122./*Write a program to print the structure variable pass in function*/

#include<stdio.h>
#include<conio.h>
struct student
{
            int rollno;
            char name[40];
            };
            void main()
            {
            struct student s1;
            clrscr();

            printf("Enter roll number and name of the student:\n");
            scanf("%d%s",&s1.rollno,s1.name);
            display(s1);
            getch();
            }
            display(struct student s)
            {
             printf("\nThe roll number of the student is:%d\n",s.rollno);
             printf("\nThe name of the student is:%s",s.name);
}

OUTPUT

            Enter roll number and name of the student:
            23 RAM KUMAR
           
            The roll number of the student is: 23
           
The name of the student is: RAM KUMAR

123./*Write a program to print the use of pointer in structure*/

#include<stdio.h>
#include<conio.h>
struct student
{
 int rollno;
 char name[20];
 };
 void main()
 {
 struct student s1={123,"mahesh"};
 struct student *sptr;
 clrscr();

 sptr=&s1;
 printf("\nThe details with the help of structure variable.....\n\n");
 printf("The roll number of the student is%d\n\n",s1.rollno);
 printf("The name of the student is%s\n\n",s1.name);
 printf("\nNow the details with the help of pointer.....\n\n");
 printf("\nThe roll number of the student is%d\n\n",sptr->rollno);
 printf("The name of the student is %s\n\n",sptr->name);
 getch();
 }


OUTPUT
                  The details with the help of structure variable....

   

     The roll number of the student is123


                 The name of the student is mahesh

                 Now the details with the help of pointer.....

                 The roll number of the student is123

                 The name of the student is mahesh
           







No comments:

Post a Comment