Divyen jiyani

મળો Mને ફેસબુક પર
Divyen jiyani

Assignment Program 1. Write a program to print “Hello World” message.

#include<stdio.h>

#include<conio.h>

void main()

{

  clrscr();

  printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");

  printf("                       **************************************");

  printf("\n                       *          Hello World               * ");

  printf("\n                       **************************************");

  getch();

}

2. Write a program to print Name , Address and Birth Date1. Write a program to print “Hello World” message.1. Write a program to print “Hello World” message.

#include<stdio.h>

#include<conio.h>

void main()

{

   clrscr();

   printf("**************************\n");

   printf("* presonal Information   *\n");

   printf("**************************");

   printf("\nName    : Divyen R. Jiyani\n");

   printf("Address : B/20 Surbhi Vihar,\n");

   printf("          Opp Renuka Bhavan Bombay market to punagam raod,\n");

   printf("          Surat.\n");

   printf("Email ID: Divyenr@yahoo.com");

   getch();

3. Write a program to add, multiply and divide two integers and float numbers.

#include<stdio.h>

#include<conio.h>

void main()

{

   clrscr();

   printf("Defination....\nW.A.P to  Add  ,Mul,Div between Two number Data type Int and Float use");

   float a,b,c,d;

   printf("\nEntre a First Number:-->");

   scanf("%f",&a);

   printf("\nEntre a Second number:-->");

   scanf("%f",&b);

   c=a+b;

   d=a*b;

   printf("\nAddition is %f and %f = %f\n\n",a,b,c);

   printf("\nMultipilication is %f and %f = %f",a,b,d);

   getch();

}

4. Write a program to convert Rupees(float) to paisa(int)1. Write a program to print “Hello World” message.1. Write a program to print “Hello World” message.

#include<stdio.h>

#include<conio.h>

void main()

{

  clrscr();

  printf("Defination....\nW.A.P to covert Rupes(float) to paisa(int)");

  float r;

  int p;

  printf("\nEntre a Rupees:-->");

  scanf("%f",&r);

  p=r*100;

  printf("\nRupees are %f convert in paisa =%d paisa",r,p);


  getch();

}

5. Write a program to accept number of days and print year, month and remaining days.

#include<conio.h>

#include<stdio.h>

void main()

{

int days,yr,mon,rn_days;

clrscr();


printf("Enter Days:");

scanf("%d",&days);


yr=days/365;

printf("\nYear: %d",yr);


mon=(days-(yr*365))/30;

printf("\nMonth: %d",mon);


rn_days=days-((yr*365)+(mon*30));

printf("\nRemaining days :: %d",rn_days);


getch();

}

6. Write a program to check whether the entered number is prime or not.

#include<stdio.h>

#include<conio.h>

void main()


{


    int num,i,count=0;

    printf("Enter a number: ");

    scanf("%d",&num);

    for(i=2;i<=num/2;i++){

        if(num%i==0){

         count++;

            break;

        }

    }

   if(count==0 && num!= 1)

        printf("%d is a prime number",num);

   else

      printf("%d is not a prime number",num);

   getch();

}

7. Write a program to check whether the entered number is even or odd.

#include<stdio.h>

#include<conio.h>

void main()

{

    int no;

    clrscr();

    printf("enter velue of no");

    scanf("%d",&no);

    if(no%2==0);

    {

    printf("no is ever");

    }

    else

    {

    printf("no is odd");

    }

    getch();

}


8. Using While loop print 1 2 3 4 5 …..10.

//Using While loop print 1 2 3 4 5...10

#include<stdio.h>

#include<conio.h>


void main()

{

int n;

clrscr();

n=0;

while (n != 10)

{

n++;

printf(" %d",n);

}

getch();

}

9. Print series 2, 4, 6, 8,…….n.

// series print 2,4,6,8,......n . getting n by the user.

#include<stdio.h>

#include<conio.h>


void main()

{

int n,a;

clrscr();

printf("enter the number ::");

scanf("%d",&n);

a=2;

while ( n != 0)

{

printf(" %d",a);

a += 2;

n--;

}

getch();

}

10. Print series 2, 4, 16,……n*n using shorthand operator and while loop

//print series 2,4,16, .........n where n is getting by user

#include<stdio.h>

#include<conio.h>

#include<math.h>



void main()

{

int n,a,c,d;

clrscr();

printf("enter the number ::");

scanf("%d",&n);

a=2;

c=2;

printf("%d",a);

n--;

while ( n != 0)

{

d=pow(a,c);

printf(" \n%d" ,d);

c = c+2;

n--;

}

getch();

}

11. Write a program to generate fibonnacci series.

#include<stdio.h>

#include<conio.h>

 

main()

{

   int n, first = 0, second = 1, next, c;

 

   printf("Enter the number of terms ");

   scanf("%d",&n);

 

   printf("First %d terms of fibonacci series are :-\n",n);

 

   for ( c = 0 ; c < n ; c++ )

   {

      if ( c <= 1 )

         next = c;

      else

      {

         next = first + second;

         first = second;

         second = next;

      }

      printf("%d\n",next);

   }

 

   getch();

   return 0;

}

12. Write a program to print the multiplication table.

//wap for multiplication table

#include<stdio.h>

#include<conio.h>


void main()

{

int a,b,n,i;

clrscr();

printf("enter the value for table you want :: ");

scanf("%d",&n);


printf("\n table of %d is under ",n);

printf("\n======================\n");


for (i=1;i<=10;i++)

{

a=n*i;

printf(" %d * %d  = %d\n",n,i,a);

}

printf("\n======================\n");

getch();

}


< 13. Write a program to find a factorial of the entered number.

//factorial of n number

#include<stdio.h>

#include<conio.h>

#include<math.h>


void main()

{

int n,a,c,d;

a=1;

clrscr();

printf("enter the number ::");

scanf("%d",&n);

while ( n != 0)

{

a= n*a;

n--;

}

printf("factorial number is::%d",a);

getch();

}

14. Write a program to print all the numbers and sum of all the integers that are greater than 100 and less than 200 and are divisible by 7.

//print the all no and sum the no which is devided by 7 

//between 100 to 200

#include<stdio.h>

#include<conio.h>


void main()

{

int sum,i;

clrscr();

sum=0;

printf("\nthe value is devided by 7 between the 100 to 200 is under \n\n");

for(i=100;i<=200;i++)

{

if(i % 7 == 0)

{

printf("\t\t\t\t%d\n",i);

sum=sum+i;

}

}

printf("                              =====\n");

printf("      the sum of above no is:: %d",sum);

getch();

}


15. Write a program to find the roots of an equation ax2 + bx + c = 0.

// find roots of equation ax2(square)+bx+c=0



#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,c,delta,ans1,ans2;

clrscr();

printf("enter value of A:");

scanf("%d",&a);

printf("enter value of B:");

scanf("%d",&b);

printf("enter value of C:");

scanf("%d",&c);

delta=(b*b)-(4*a*c);

if(delta>0)

{

ans1=(float)(-b+(sqrt(delta)))/(2*a);

ans2=(float)(-b-(sqrt(delta)))/(2*a);

printf("roots of equation are=%d%d",ans1,ans2);

}

else if(delta<0)

{

  printf("roots are imaginary");


}

else if(delta==0)

{

ans1=(-b)/(2*a);

printf("roots is=%d",ans1);

}


getch();

}

16. Write a program that accept basic, HRA, and convergence from the user and calculate total salary.

// wap that accept basic ,hra,convergence from user and

// calculate total salary


#include<stdio.h>

#include<conio.h>


void main()

{

int basic;

float hra, c, t;

clrscr();

printf("\n enter the basic :: ");

scanf("%d",&basic);

printf("\n enter the HRA :: ");

scanf("%f",&hra);

printf("\n enter the convergence :: ");

scanf("%f",&c);

t=basic+hra-c;

printf("\n=======================\n")    ;

printf("\n total salary is :: %.2f",t);

getch();

}

17. Print the following triangle.

// generate a b c d e

//           a b c d

//            a b c

//             a b

//              a


#include<stdio.h>

#include<conio.h>


void main()

{

int a,k,j,i,n;

clrscr();

printf("enter the no for series :: ");

scanf("%d" ,&n );


for(i=0;i<n;i++)

{

a=97;

for(k=0;k<i;k++)

{

printf(" ");

}

for(j=i;j<n;j++)

{

printf("%c ",a);

a++;

}


printf("\n");

}

getch();

}


18. Write a program that prints the following Floyd’s triangle.

// wap to print floyd's triangle

// 1

// 2 3

// 4 5 6

// 7 8 9 10

// 11 12 13 14 15

// .

// .

// 79.................91


#include<stdio.h>

#include<conio.h>


void main()

{

int k,i,j,n;

clrscr();

printf("enter the value for froyd's triangle ::");

scanf("%d",&n);

k=1;

for(i=1;i<=n;i++)

{

for(j=0;j<i;j++)

{

printf("%d ",k);

k++;

}

printf("\n");

}

getch();

}

19. Write a program to find maximum element from 1-Dimensional array.

//wap to find maximum element from 1- dimensional array


#include<stdio.h>

#include<conio.h>


void main()

{

int a[50],i,j,max,n;

clrscr();

printf("enter the size of array ::");

scanf("%d",&n);

clrscr();

printf("enter the element of array");

for(i=1;i<=n;i++)

{

printf("\nenter the a[%d] ::",i);

scanf("%d",&a[i]);

}

max=0;

for(i=0;i<=n;i++)

{

if(a[i] > max)

max=a[i];

}

printf("\nmax element of array is %d",max);

getch();

}


20. Write a program to sort given array in ascending order.

//Write a program to sort given array in ascending order.

#include<stdio.h>

#include<conio.h>



void main()

{

int a[50],i,j,k,n;

clrscr();

printf("enter the size of array ::");

scanf("%d",&n);

clrscr();

printf("enter the element of array");

for(i=0;i<n;i++)

{


printf("\nenter the a[%d] ::",i+1);

scanf("%d",&a[i]);

}

for(i=0;i<n;i++)

{

for(j=0;j<n-(i+1);j++)

{

if(a[j] > a[j+1])

{

k=a[j];

a[j]=a[j+1];

a[j+1]=k;

}

}

}

printf("\n==array in assending order is under===");

for(i=0;i<n;i++)

{

printf("\nenter the a[%d] is ::%d",i+1,a[i]);

}

getch();

   }

21. Given the two 1-D arrays A and B, which are sorted in ascending order. Write a program to merge them into a single sorted array C that contains every item from arrays A and B, in ascending order.

/*Given the two 1-D arrays A and B, which are sorted in ascending order. Write a

program to merge them into a single sorted array C that contains every item from

arrays A and B, in ascending order.*/

#include<stdio.h>

#include<conio.h>


void main()

{

int a[50],b[50],c[100],i,j,k,n,n1,n2,l;

clrscr();

// firstr array

printf("enter the size of array A ::");

scanf("%d",&n);

printf("\nenter the element of array");

for(i=0;i<n;i++)

{

printf("\nenter the a[%d] ::",i+1);

scanf("%d",&a[i]);

}


// first array sorting

for(i=0;i<n;i++)

{

for(j=0;j<n-(i+1);j++)

{

if(a[j] > a[j+1])

{

k=a[j];

a[j]=a[j+1];

a[j+1]=k;

}

}

}

printf("\n==first array accending order is ===");

for(i=0;i<n;i++)

{

printf("\nenter the c[%d] is ::%d",i+1,a[i]);

}

getch();


// second array

clrscr();

printf("enter the size of array B ::");

scanf("%d",&n1);

n2 = n + n1;

printf("enter the element of array");

for(i=0;i<n1;i++)

{

printf("\nenter the a[%d] ::",i+1);

scanf("%d",&b[i]);

}

for(i=0;i<n1;i++)

{

for(j=0;j<n1-(i+1);j++)

{

if(b[j] > b[j+1])

{

k=b[j];

b[j]=b[j+1];

b[j+1]=k;

}

}

}

printf("\n==second array accending order is ===");

for(i=0;i<n;i++)

{

printf("\nenter the c[%d] is ::%d",i+1,b[i]);

}


// third array merge

clrscr();

for(i=0;i<n;i++)

  c[i]=a[i];

for(j=0;j<n1;j++)

{

c[i]=b[j];

i++;

}

getch();

printf("\n==third array is under===");

for(i=0;i<n2;i++)

{

printf("\nenter the c[%d] is ::%d",i+1,c[i]);

}


for(i=0;i<n2;i++)

{

for(j=0;j<n2-(i+1);j++)

{

if(c[j] > c[j+1])

{

k=c[j];

c[j]=c[j+1];

c[j+1]=k;

}

}

}

printf("\n==third array accending order is ===");

for(i=0;i<n2;i++)

{

printf("\nenter the c[%d] is ::%d",i+1,c[i]);

}

getch();

}

22. Write a program to add two matrices.

//Write a program to add two matrices.

#include<stdio.h>

#include<conio.h>


void main()

{

int a[10][10],b[10][10],c[10][10],n,ac,ar,bc,br,i,j;


clrscr();

// firstr matrix

printf("\t\t first matrix \n");

printf("matrix collum size ::");

scanf("%d",&ac);

printf("matrix raw size::");

scanf("%d",&ar);


printf("\n enter the element of matrix\n");

for(i=0;i<ac;i++)

{

for(j=0;j<ar;j++)

{

printf("enter the a[%d,%d] ::",i,j);

scanf("%d",&a[i][j]);

}

}


printf("\n== first matrix is ===\n");

for(i=0;i<ac;i++)

{

for(j=0;j<ar;j++)

{

printf("\t %d ",a[i][j]);

}

printf("\n");

}

getch();

clrscr();

printf("\t\t second matrix \n");

printf("enter the matrix collum ::");

scanf("%d",&bc);

printf("\n enter the matrix raw ::");

scanf("%d",&br);


printf("\n enter the element of matrix \n");

for(i=0;i<bc;i++)

{

for(j=0;j<br;j++)

{

printf("enter the [%d,%d] : ",i,j);

scanf("%d",&b[i][j]);

}

}


printf("\n == second matrix is ==\n");

for(i=0;i<bc;i++)

{

for(j=0;j<br;j++)

{

printf("\t%d ",b[i][j]);

}

printf("\n");

}

getch();


// addition of two matrix

if (ac==bc && ar==br)

{

for(i=0;i<ac;i++)

{

for(j=0;j<br;j++)

{

c[i][j]=a[i][j] + b[i][j];

}

}

printf("\n addition of two matrix is \n");

for(i=0;i<ac;i++)

{

for(j=0;j<br;j++)

{

printf("\t%d ",c[i][j]);

} printf("\n");

}

}

else

printf("\n addition of two matrix is not perform \n");

getch();

}

23. Write a program to find string length.

//Write a program to find string length.

#include<stdio.h>

#include<conio.h>


void main()

{

char a[50];

int i=0;

clrscr();


printf("enter string ::");

gets(a);

while (a[i] !='\0')

{

i++;

}

printf("STRING length is :: %d",i);

getch();

}





24. Write a program to print size of int, float, double variable.

//Write a program to print size of int, float, double variable.

#include<stdio.h>

#include<conio.h>


void main()

{

clrscr();

printf(" size of integer is:: %d byte", sizeof(int));

printf("\n size of float is:: %d byte", sizeof(float));

printf("\n size of double is:: %d byte",sizeof(double));

getch();

}

25. Write a program that will read a text and count all occurrences of a particular word.

//Write a program that will read a text and count all occurrences of a particular

//word.

#include<stdio.h>

#include<conio.h>

#include<string.h>



void main()

{

int   i,j,n,n1,f,s2;

char  a[50],b[50],c[50];

clrscr();


printf("enter string ::");

gets(a);

printf("enter word you are search ::");

gets(b);


n=strlen(a);

n--;

n1=strlen(b);


i=0;

f=0;

while(i <= n)

{


   if(isspace(a[i]))

   {

while(isspace(a[i]) != 0)

i++;

   }

   j=0;

   while(j != n1)

   {

if( b[j]==a[i])

{

j++;i++;

if(j==n1)

{f++;}

}

else

{

break ;

}

   }

   i++;

}

if(f==0)

printf("word is not in string ");

else

printf("Ocuurency of word is :: %d",f);

getch();

}

26. Write a program that will read a string and rewrite it in the alphabetical order. i.e. the word STRING should be written as GINRST.

//Write a program that will read a string and rewrite it in the alphabetical order. i.e.

//the word STRING should be written as GINRST.

#include<stdio.h>

#include<conio.h>


void main()

{

int n,i;

char a[20];

clrscr();

printf("ENTER THE STRING ::");

gets(a);


n=strlen(a);


printf("\n ==REWRITE STRING IS== \n") ;

for (i=n-1 ; i >=0 ;i--)

{

printf("%c",a[i]);

}

getch();

}

27. Write a program that appends the one string to another string.

//Write a program that appends the one string to another string.

#include<stdio.h>

#include<conio.h>


void main()

{

int n,i;

char a[20],b[20],c[41];


clrscr();

printf("ENTER FIRST STRING ::");

gets(a);


printf("ENTER SECOND STRING ::");

gets(b);


strcpy(c,a);

strcat(c,b);



printf("====AFTER APPENDS TWO STRINGS IS====\n");

puts(c);

getch();

}


28. Write a program that finds a given word in a string.

//Write a program that finds a given word in a string.

#include<stdio.h>

#include<conio.h>

#include<string.h>



void main()

{

int   i,j,n,n1,f,s2;

char  a[20],b[10],c[10];

clrscr();


printf("enter string ::");

gets(a);

printf("enter word you are search ::");

gets(b);


n=strlen(a);

n--;

n1=strlen(b);


i=0;

f=0;

while(i != n)

{

   if(isspace(a[i]))

   {

while(isspace(a[i]) != 0)

i++;

   }

   j=0;

   while(j != n1)

   {

if( b[j]==a[i])

{

j++,i++;

if(j==n1)

{    f=0;

goto location;

}

}

else

{

f=1;

break ;

}

   }

   i++;

}

location:


if(f==1)

printf("word is not in string ");

else

printf("word is in given string");


getch();

}

coming soon 29 to 42

By Divyen jiyani

Mo :9714240720

 


Enter a your Email_id For Show next update in your mail

free templates
Make a Free Website with Yola.