Saturday, March 25, 2023

add ,substact ,multiply ,divide two numbers using switch statement .

 //add ,substact ,multiply ,divide two numbers using switch statement

#include <stdio.h>
int main (){
    int a,b,ch,c ;
    printf ("enter two number  and ch\n");
    scanf ("%d%i%d",&a,&b,&ch);
   
    switch(ch){
        case 1:c=a+b;
        printf ("%d",c);
        break;
        case 2:c=a-b;
        printf ("%d",c);      
         break;
        case 3:c=a*b;
        printf ("%d",c);
        break;
        case 4:c=a/b;
        printf ("%d",c);
        break;

    }
    return 0;
}

Tuesday, March 21, 2023

find the lcm of any two numbers in c.

  //find the lcm of any two numbers

 #include <stdio.h>
 int main (){
    int num1,num2,i,hcf,lcm ;
    printf ("enter two numbers :");
    scanf ("%i%i",&num1,&num2);
    for (i=1;i<=num1&&i<=num2;i++){
        if (num1%i==0 && num2%i==0){
            hcf =i;
        }
    }
    lcm=(num1*num2)/hcf ;
    printf ("lcm of %i and %i is %i ",num1,num2,lcm);
    return 0;
 }

find the hcf of any two numbers in c

  //find the hcf of any two numbers

 #include <stdio.h>
 int main (){
    int num1,num2,i,hcf ;
    printf ("enter two numbers :");
    scanf ("%i%i",&num1,&num2);
    for (i=1;i<=num1&&i<=num2;i++){
        if (num1%i==0 && num2%i==0){
            hcf =i;
        }
    }
     
    printf ("hcf of %i and %i is %i ",num1,num2,hcf);
    return 0;
 }

Monday, March 20, 2023

size of integer ,float,character,double data type in c

 //size of integer ,float,character,double data  type

#include <stdio.h>
int main (){
    int i;
    char c ;
    float f ;
    double d ;
    printf ("size of integer is :%ld byte\n ",sizeof (i));
     printf ("size of charecter is :%ld byte\n ",sizeof (c));
      printf ("size of float  is :%ld byte \n",sizeof (f));
       printf ("size of double is :%ld byte\n ",sizeof (d));
       return 0;
}

output output output output output
size of integer is :4 byte size of charecter is :1 byte size of float is :4 byte size of double is :8 byte

Sunday, March 19, 2023

print "hallo eworld " without using semi colon (;)

 //print "hallo eworld " without using semi colon (;)

#include <stdio.h>
int main (){
    if (printf ("hallo world "))
    return 0;
}

"print the fibonacchi series using c'' in c

 //print the fibonacchi series using c

#include <stdio.h>
int main (){
    int num1=0,num2=1,num3,i,upto;
    printf ("series will go upto :");
    scanf ("%d",&upto);
    printf ("%d %d ",num1,num2);
    for (i=2;i<upto;i++){
        num3=num1+num2 ;
        printf ("%d ",num3);
        num1=num2;
        num2=num3;
    }
    return 0;
}

OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT

series will go upto :15 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377

"find a year is leap year or not ,using if else statement " in c .

  //find a year is leap year or not, using if else statement

 # include <stdio.h>
 int main (){
    int y;
    printf ("enter the year  :");
    scanf ("%i",&y);
    if (y%4==0){
        if (y%100==0){
            if (y%400==0)
                printf ("%i is a leap year ",y);
                else
                 printf ("%i is  not a leap year ",y);
        }
           
            else printf ("%i is a leap year ",y);
        }
        else printf ("%i is  not a leap year ",y);

        return 0;
    }
 
 

"multiplication table for any integer " in c .

  //multiplication table for any integer

 #include <stdio.h>
 int main (){
    int number ,i;
    printf ("enter the value of an integer :");
    scanf ("%i",&number );
    printf ("the multiplication table of %i is : \n",number );
    for (i=1;i<=10;i++){
        printf ("%i*%i=%i\n",number ,i,number *i);
       
    }
    return 0;
 }
output output output output output

enter the value of an integer :9 the multiplication table of 9 is : 9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81 9*10=90

"print the all character from 'A' to 'Z' using for loop" in c

 //print the all character from 'A' to 'Z' using  for loop


#include <stdio.h>
int main (){
    char cr;
for (cr='A';cr<='Z';cr++){
    printf ("%c ",cr);
}
return 0;
}

output output output output output output output 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 

"find the average of two given numbers " using c .

//find the average of two given numbers
#include <stdio.h>
int main (){
    int num1,num2 ;
    float avr;
    printf ("enter two numbers :");
    scanf ("%i%i",&num1,&num2);
    avr =(float)(num1+num2)/2;
    printf ("the value of average of two  numbers is :%.2f",avr);
    return 0;
}

"find the gretest number between three numbers " in c programming .

 //find the gretest number between three numbers

#include <stdio.h >
int main (){
    int a,b,c;
    printf ("enter three numbers :");
    scanf ("%d%d%d",&a,&b,&c);
    if (a>b && b>c){
        printf ("%d is the gretest number",a);
    }
    else if (b>c&&c>a){
          printf ("%d is the gretest number",b);
    }
    else if (c>a&&a>b){
          printf ("%d is the gretest number",c);
    }
    else {
        printf ("all numbers are equal");
    }
    return 0;
}

Saturday, March 18, 2023

"print a star pattern with 9 row and 9 column " in c programming .

 //print a star pattern with 9 row and 9 column

#include <stdio.h>
int main ()
{
    int row ,col;
    for (row=1;row<=9;row++){
        for (col=1;col<=row;col++){
            printf ("*");
        }
        printf ("\n");
    }
    return 0;
}


output output output output output
* ** *** **** ***** ****** ******* ******** *********

Friday, March 17, 2023

"find the reverse number using while loop " using c .

 //find the reverse number using while loop

#include <stdio.h>
int main (){
int num,rem;
printf ("enter the value of number ");
scanf ("%i",&num);
while (num>0){
    rem=num%10;
     
    printf ("%i",rem);
num=num/10;
}
return 0;
}

"find a number positive or negative using if-else statement " in c

 //find a number  positive or negative using if-else statement

#include <stdio.h>
int main (){
    int num;
    printf ("Enter the number :");
    scanf ("%i",&num);
    if (num>0){
        printf ("%i is the positive number ",num);
    }
    else if(num<0) {
        printf ("%i is the negative number ",num);}
else {
    printf ("0 is the neither positive nor negative ");
}
return 0;

}


"programme to check whether a number odd or even using modulo operator " using c

 //programme to check whether a number odd or even using modulo operator

#include <stdio.h>
int main (){
    int num;
    printf ("entr the number :");
    scanf ("%i",&num);
    if (num%2==0){
        printf ("%i is the even number ",num);

    }
    else {
             printf ("%i is the odd number ",num);
    }
    return 0;
}

"find the value of hcf of two numbers " using c

 //find the value of hcf of two numbers


#include <stdio.h>
int main (){
    int n1,n2,hcf ,i;
    printf ("enter the value of two numbers :");
    scanf ("%i%i",&n1,&n2);
    for (i=1;i<=n1||i<=n2;i++){
        if (n1%i==0 && n2%i==0){
            hcf =i;
        }

    }
printf ("the value of hcf of n1 and n2 is %i\n",hcf );
return 0;
}

"create "hi I love you c" programme using c " with output

//create "hi I  love you c" programme  using c 10 times
#include <stdio.h>
int main (){
    int i,n;
printf ("enter the value of n :");
scanf ("%i",&n);
for (i=1;i<=n;i=i+1){
    printf ("hi I  love you c\n");
}
return 0;
}



OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT

hi I love you c hi I love you c hi I love you c hi I love you c hi I love you c hi I love you c hi I love you c hi I love you c hi I love you c hi I love you c

"find the factorial of any positive integer using for loop " in c programming .

 //find the factorial of any positive integer using  for loop

#include <stdio.h>
int main (){
    int i,n,fact=1 ;
    printf  ("enter the value of n :");
    scanf ("%i",&n);
    for (i=n;i>=1;i--){
        fact =fact*i;
    }
    printf ("the factorial of n is %i",fact );
    return 0;
}

"find the sum of the series 1^2+3^2+5^2+...+n^2 using for loop" using c .

  //find the sum of the series 1^2+3^2+5^2+...+n^2  using for loop

 //where  n is the positive odd integer
 #include <stdio.h >
 int main ()
 {
    int n,i,sum ;
    printf ("enter any positive odd integer  i.e n :");
    scanf ("%i",&n);
for (i=1;i<=n;i=i+2){
    sum=sum + i*i;
}
printf ("the  sum of the series is :%i",sum);
return 0;
 }

"find the sum of the series 2^2+4^2+6^2+...+n^2 using for loop" in c .

  //find the sum of the series 2^2+4^2+6^2+...+n^2 using for loop

 //where  n is the positive even integer
 #include <stdio.h >
 int main ()
 {
    int n,i,sum ;
    printf ("enter any positive even integer  i.e n :");
    scanf ("%i",&n);
for (i=2;i<=n;i=i+2){
    sum=sum + i*i;
}
printf ("the  sum of the series is :%i",sum);
return 0;
 }

"sum of the 1^4+2^4+3^4+...+n^4 using c " by c

 //sum of the 1^4+2^4+3^4+...+n^4 using c

#include <stdio.h>
int main (){
    int i,n,power4;
    printf ("enter the value of n :");
    scanf ("%i",&n);
    for (i=1;i<=n;i++){
        power4=power4 + i*i*i*i;
    }
    printf ("the sum of 1st power4 upto n is : %i",power4);
    return 0;
}

"find the sum of the series 1^3+2^3+3^3+...+n^3 number" using c .

 //find the sum of the series 1^3+2^3+3^3+...+n^3 number

#include <stdio.h >

int main (){
    int n,i,cube ;
    printf ("enter the value of n :");
    scanf ("%i",&n);
    for (i=1;i<=n;i++){
        cube =cube + i*i*i;
    }
    printf ("the sum of cube of 1st n  number is :%d",cube );
    return 0;
}


print a multiplication table of any integer taking from user

 // print a multiplication table of any integer taking from user  #include "stdio.h" int main () { int n,mul,i; printf ("...